@@ -21,24 +21,31 @@ using namespace std;
21
21
22
22
primo::ref<MediaSocket> createOutputSocket (Options& opt)
23
23
{
24
- auto socket = primo::make_ref (Library::createMediaSocket ());
25
- socket->setFile (primo::ustring (opt.outputFile ));
26
- socket->setStreamType (StreamType::AAC);
27
- socket->setStreamSubType (StreamSubType::AAC_ADTS);
28
-
29
- auto pin = primo::make_ref (Library::createMediaPin ());
30
- socket->pins ()->add (pin.get ());
31
-
24
+ // create stream info to describe the output audio stream
32
25
auto asi = primo::make_ref (Library::createAudioStreamInfo ());
33
- pin->setStreamInfo (asi.get ());
34
-
35
26
asi->setStreamType (StreamType::AAC);
36
27
asi->setStreamSubType (StreamSubType::AAC_ADTS);
37
28
38
29
// You can change the sampling rate and the number of the channels
39
- // asi->setChannels(1 );
40
- // asi->setSampleRate(44100 );
30
+ // asi->setSampleRate(44100 );
31
+ // asi->setChannels(1 );
41
32
33
+ // create a pin using the stream info
34
+ auto pin = primo::make_ref (Library::createMediaPin ());
35
+ pin->setStreamInfo (asi.get ());
36
+
37
+ // finally create a socket for the output container format
38
+ // which in this cases is is AAC packaged as Audio Data Transport Stream (ATDS)
39
+ auto socket = primo::make_ref (Library::createMediaSocket ());
40
+ socket->setStreamType (StreamType::AAC);
41
+ socket->setStreamSubType (StreamSubType::AAC_ADTS);
42
+
43
+ socket->pins ()->add (pin.get ());
44
+
45
+ // output to a file
46
+ auto output_file = primo::ustring (opt.outputFile );
47
+ socket->setFile (output_file);
48
+
42
49
return socket;
43
50
}
44
51
0 commit comments