Skip to content

Commit f40e648

Browse files
committed
Auto push on 2024-05-08 12:55:40
1 parent b6d8224 commit f40e648

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

samples/darwin/enc_aac_adts_file/enc_aac_adts_file.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,31 @@ using namespace std;
2121

2222
primo::ref<MediaSocket> createOutputSocket(Options& opt)
2323
{
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
3225
auto asi = primo::make_ref(Library::createAudioStreamInfo());
33-
pin->setStreamInfo(asi.get());
34-
3526
asi->setStreamType(StreamType::AAC);
3627
asi->setStreamSubType(StreamSubType::AAC_ADTS);
3728

3829
// 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);
4132

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+
4249
return socket;
4350
}
4451

0 commit comments

Comments
 (0)