diff --git a/packager/media/base/media_handler.h b/packager/media/base/media_handler.h index b74fa65b0b..560549aa0f 100644 --- a/packager/media/base/media_handler.h +++ b/packager/media/base/media_handler.h @@ -44,12 +44,12 @@ struct StreamData { int stream_index = -1; StreamDataType stream_data_type = StreamDataType::kUnknown; - std::unique_ptr period_info; - std::unique_ptr stream_info; - std::unique_ptr encryption_config; - std::unique_ptr media_sample; - std::unique_ptr media_event; - std::unique_ptr segment_info; + std::shared_ptr period_info; + std::shared_ptr stream_info; + std::shared_ptr encryption_config; + std::shared_ptr media_sample; + std::shared_ptr media_event; + std::shared_ptr segment_info; }; /// MediaHandler is the base media processing unit. Media handlers transform @@ -111,7 +111,7 @@ class MediaHandler { /// Dispatch the period info to downstream handlers. Status DispatchPeriodInfo(int stream_index, - std::unique_ptr period_info) { + std::shared_ptr period_info) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; stream_data->stream_data_type = StreamDataType::kPeriodInfo; @@ -121,7 +121,7 @@ class MediaHandler { /// Dispatch the stream info to downstream handlers. Status DispatchStreamInfo(int stream_index, - std::unique_ptr stream_info) { + std::shared_ptr stream_info) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; stream_data->stream_data_type = StreamDataType::kStreamInfo; @@ -142,7 +142,7 @@ class MediaHandler { /// Dispatch the media sample to downstream handlers. Status DispatchMediaSample(int stream_index, - std::unique_ptr media_sample) { + std::shared_ptr media_sample) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; stream_data->stream_data_type = StreamDataType::kMediaSample; @@ -152,7 +152,7 @@ class MediaHandler { /// Dispatch the media event to downstream handlers. Status DispatchMediaEvent(int stream_index, - std::unique_ptr media_event) { + std::shared_ptr media_event) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; stream_data->stream_data_type = StreamDataType::kMediaEvent; @@ -162,7 +162,7 @@ class MediaHandler { /// Dispatch the segment info to downstream handlers. Status DispatchSegmentInfo(int stream_index, - std::unique_ptr segment_info) { + std::shared_ptr segment_info) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; stream_data->stream_data_type = StreamDataType::kSegmentInfo; diff --git a/packager/media/base/media_handler_test_base.cc b/packager/media/base/media_handler_test_base.cc index d4630a7f7c..0f843324ad 100644 --- a/packager/media/base/media_handler_test_base.cc +++ b/packager/media/base/media_handler_test_base.cc @@ -133,16 +133,17 @@ void MediaHandlerTestBase::ClearOutputStreamDataVector() { next_handler_->clear_stream_data_vector(); } -std::unique_ptr MediaHandlerTestBase::GetMockStreamInfo( - Codec codec, uint32_t time_scale) { +std::shared_ptr MediaHandlerTestBase::GetMockStreamInfo( + Codec codec, + uint32_t time_scale) { if (codec >= kCodecAudio && codec < kCodecAudioMaxPlusOne) { - return std::unique_ptr(new AudioStreamInfo( + return std::shared_ptr(new AudioStreamInfo( kTrackId, time_scale, kDuration, codec, kCodecString, kCodecConfig, sizeof(kCodecConfig), kSampleBits, kNumChannels, kSamplingFrequency, kSeekPrerollNs, kCodecDelayNs, kMaxBitrate, kAvgBitrate, kLanguage, !kEncrypted)); } else if (codec >= kCodecVideo && codec < kCodecVideoMaxPlusOne) { - return std::unique_ptr(new VideoStreamInfo( + return std::shared_ptr(new VideoStreamInfo( kTrackId, time_scale, kDuration, codec, kCodecString, kCodecConfig, sizeof(kCodecConfig), kWidth, kHeight, kPixelWidth, kPixelHeight, kTrickPlayRate, kNaluLengthSize, kLanguage, !kEncrypted)); diff --git a/packager/media/base/media_handler_test_base.h b/packager/media/base/media_handler_test_base.h index e6286e29f0..ba7e84bab5 100644 --- a/packager/media/base/media_handler_test_base.h +++ b/packager/media/base/media_handler_test_base.h @@ -85,7 +85,7 @@ class MediaHandlerTestBase : public ::testing::Test { MediaHandlerTestBase& operator=(const MediaHandlerTestBase&) = delete; // Get a mock stream info for testing. - std::unique_ptr GetMockStreamInfo(Codec codec, + std::shared_ptr GetMockStreamInfo(Codec codec, uint32_t time_scale); // Downstream handler used in testing graph. diff --git a/packager/media/chunking/chunking_handler.h b/packager/media/chunking/chunking_handler.h index 67f876a747..4db1d74dad 100644 --- a/packager/media/chunking/chunking_handler.h +++ b/packager/media/chunking/chunking_handler.h @@ -110,8 +110,8 @@ class ChunkingHandler : public MediaHandler { // Current subsegment index, useful to determine where to do chunking. int64_t current_subsegment_index_ = -1; - std::vector> segment_info_; - std::vector> subsegment_info_; + std::vector> segment_info_; + std::vector> subsegment_info_; std::vector time_scales_; // The end timestamp of the last dispatched sample. std::vector last_sample_end_timestamps_;