7 #include "packager/media/base/media_stream.h"
9 #include "packager/base/logging.h"
10 #include "packager/base/strings/stringprintf.h"
11 #include "packager/media/base/demuxer.h"
12 #include "packager/media/base/media_sample.h"
13 #include "packager/media/base/muxer.h"
14 #include "packager/media/base/stream_info.h"
20 : info_(info), demuxer_(demuxer), muxer_(NULL), state_(kIdle) {}
22 MediaStream::~MediaStream() {}
25 DCHECK(state_ == kPulling || state_ == kIdle);
28 while (samples_.empty()) {
34 *sample = samples_.front();
43 samples_.push_back(sample);
48 return muxer_->AddSample(
this, sample);
50 NOTREACHED() <<
"Unexpected State " << state_;
51 return Status::UNKNOWN;
64 DCHECK(operation == kPush || operation == kPull);
69 state_ = kDisconnected;
73 state_ = (operation == kPush) ? kPushing : kPulling;
74 if (operation == kPush) {
76 while (!samples_.empty()) {
77 Status status = muxer_->AddSample(
this, samples_.front());
85 for (
size_t i = 0; i < demuxer_->
streams().size(); ++i) {
93 DCHECK(operation == kPull);
96 NOTREACHED() <<
"Unexpected State " << state_;
97 return Status::UNKNOWN;
101 const std::shared_ptr<StreamInfo> MediaStream::info()
const {
106 return base::StringPrintf(
"state: %d\n samples in the queue: %zu\n %s",
107 state_, samples_.size(), info_->ToString().c_str());