7 #include "packager/media/formats/mp2t/ts_muxer.h"
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()));
26 segmenter_->Initialize(*streams()[0]->info(), encryption_key_source(),
27 max_sd_pixels(), max_hd_pixels(),
28 max_uhd1_pixels(), clear_lead_in_seconds());
29 FireOnMediaStartEvent();
33 Status TsMuxer::Finalize() {
34 FireOnMediaEndEvent();
35 return segmenter_->Finalize();
38 Status TsMuxer::DoAddSample(
const MediaStream* stream,
39 scoped_refptr<MediaSample> sample) {
40 return segmenter_->AddSample(sample);
43 void TsMuxer::FireOnMediaStartEvent() {
44 if (!muxer_listener())
46 muxer_listener()->
OnMediaStart(options(), *streams().front()->info(),
47 kTsTimescale, MuxerListener::kContainerWebM);
50 void TsMuxer::FireOnMediaEndEvent() {
51 if (!muxer_listener())
56 const bool kHasInitRange =
true;
57 const bool kHasIndexRange =
true;
58 muxer_listener()->
OnMediaEnd(!kHasInitRange, 0, 0, !kHasIndexRange, 0, 0, 0,