7 #include "packager/media/formats/mp2t/ts_muxer.h"
9 namespace edash_packager {
14 const uint32_t kTsTimescale = 90000;
17 TsMuxer::TsMuxer(
const MuxerOptions& muxer_options) : Muxer(muxer_options) {}
18 TsMuxer::~TsMuxer() {}
20 Status TsMuxer::Initialize() {
21 if (streams().size() > 1u)
22 return Status(error::MUXER_FAILURE,
"Cannot handle more than one streams.");
24 segmenter_.reset(
new TsSegmenter(options(), muxer_listener()));
25 Status status = segmenter_->Initialize(*streams()[0]->info());
26 FireOnMediaStartEvent();
30 Status TsMuxer::Finalize() {
31 FireOnMediaEndEvent();
32 return segmenter_->Finalize();
35 Status TsMuxer::DoAddSample(
const MediaStream* stream,
36 scoped_refptr<MediaSample> sample) {
37 return segmenter_->AddSample(sample);
40 void TsMuxer::FireOnMediaStartEvent() {
41 if (!muxer_listener())
43 muxer_listener()->
OnMediaStart(options(), *streams().front()->info(),
44 kTsTimescale, MuxerListener::kContainerWebM);
47 void TsMuxer::FireOnMediaEndEvent() {
48 if (!muxer_listener())
53 const bool kHasInitRange =
true;
54 const bool kHasIndexRange =
true;
55 muxer_listener()->
OnMediaEnd(!kHasInitRange, 0, 0, !kHasIndexRange, 0, 0, 0,