try to add audio/mpeg capture

This commit is contained in:
Michel Promonet 2019-02-15 12:05:32 +00:00
parent bfed182731
commit bf6f241947
2 changed files with 13 additions and 7 deletions

View File

@ -15,29 +15,30 @@ TSServerMediaSubsession::TSServerMediaSubsession(UsageEnvironment& env, StreamRe
{
// Create a source
FramedSource* source = videoreplicator->createStreamReplica();
MPEG2TransportStreamFromESSource* muxer = MPEG2TransportStreamFromESSource::createNew(env);
if (videoformat == "video/H264") {
// add marker
FramedSource* filter = new AddH26xMarkerFilter(env, source);
// mux to TS
MPEG2TransportStreamFromESSource* muxer = MPEG2TransportStreamFromESSource::createNew(env);
muxer->addNewVideoSource(filter, 5);
source = muxer;
} else if (videoformat == "video/H265") {
// add marker
FramedSource* filter = new AddH26xMarkerFilter(env, source);
// mux to TS
MPEG2TransportStreamFromESSource* muxer = MPEG2TransportStreamFromESSource::createNew(env);
muxer->addNewVideoSource(filter, 6);
source = muxer;
}
if (audioformat == "audio/MPEG") {
// mux to TS
muxer->addNewAudioSource(source, 1);
}
FramedSource* videoSource = createSource(env, source, m_format);
FramedSource* tsSource = createSource(env, muxer, m_format);
// Start Playing the HLS Sink
m_hlsSink = MemoryBufferSink::createNew(env, OutPacketBuffer::maxSize, sliceDuration);
m_hlsSink->startPlaying(*videoSource, NULL, NULL);
m_hlsSink->startPlaying(*tsSource, NULL, NULL);
}
TSServerMediaSubsession::~TSServerMediaSubsession()

View File

@ -214,6 +214,8 @@ snd_pcm_format_t decodeAudioFormat(const std::string& fmt)
audioFmt = SND_PCM_FORMAT_MU_LAW;
} else if (fmt == "S8") {
audioFmt = SND_PCM_FORMAT_S8;
} else if (fmt == "MPEG") {
audioFmt = SND_PCM_FORMAT_MPEG;
}
return audioFmt;
}
@ -239,6 +241,9 @@ std::string getAudioRtpFormat(snd_pcm_format_t format, int sampleRate, int chann
case SND_PCM_FORMAT_S32_LE:
os << "L32";
break;
case SND_PCM_FORMAT_MPEG:
os << "MPEG";
break;
default:
os << "L16";
break;