Capture SCTE35 events

Change-Id: Id06239ed4820104fecbca08a4103a47ecbed5eda
This commit is contained in:
Kamesh Devarakonda 2017-12-11 11:59:40 -05:00
parent b3194866a6
commit 7e46ad1021
2 changed files with 32 additions and 1 deletions

View File

@ -66,8 +66,19 @@ Status ChunkingHandler::Process(std::unique_ptr<StreamData> stream_data) {
time_scales_[stream_data->stream_index] = time_scale; time_scales_[stream_data->stream_index] = time_scale;
break; break;
} }
case StreamDataType::kScte35Event: {
DCHECK_NE(main_stream_index_, kInvalidStreamIndex)
<< "kStreamInfo should arrive before kScte35Event";
const auto stream_index = stream_data->stream_index;
if (stream_index != main_stream_index_) {
VLOG(3) << "Dropping scte35 event from non main stream.";
return Status::OK;
}
scte35_events_.push(std::move(stream_data));
return Status::OK;
}
case StreamDataType::kSegmentInfo: case StreamDataType::kSegmentInfo:
VLOG(3) << "Drop existing segment info."; VLOG(3) << "Droppping existing segment info.";
return Status::OK; return Status::OK;
case StreamDataType::kMediaSample: { case StreamDataType::kMediaSample: {
const size_t stream_index = stream_data->stream_index; const size_t stream_index = stream_data->stream_index;

View File

@ -8,7 +8,9 @@
#define PACKAGER_MEDIA_CHUNKING_CHUNKING_HANDLER_ #define PACKAGER_MEDIA_CHUNKING_CHUNKING_HANDLER_
#include <atomic> #include <atomic>
#include <queue>
#include "packager/base/logging.h"
#include "packager/media/base/media_handler.h" #include "packager/media/base/media_handler.h"
#include "packager/media/public/chunking_params.h" #include "packager/media/public/chunking_params.h"
@ -99,6 +101,24 @@ class ChunkingHandler : public MediaHandler {
std::vector<uint32_t> time_scales_; std::vector<uint32_t> time_scales_;
// The end timestamp of the last dispatched sample. // The end timestamp of the last dispatched sample.
std::vector<int64_t> last_sample_end_timestamps_; std::vector<int64_t> last_sample_end_timestamps_;
struct Scte35EventComparator {
bool operator()(const std::shared_ptr<StreamData>& lhs,
const std::shared_ptr<StreamData>& rhs) const {
DCHECK(lhs);
DCHECK(rhs);
DCHECK(lhs->scte35_event);
return lhs->scte35_event->start_time > rhs->scte35_event->start_time;
}
};
// Captures all incoming SCTE35 events to identify chunking points. Events
// will be removed from this queue one at a time as soon as the correct
// chunking point is identified in the incoming samples.
std::priority_queue<std::shared_ptr<StreamData>,
std::vector<std::shared_ptr<StreamData>>,
Scte35EventComparator>
scte35_events_;
}; };
} // namespace media } // namespace media