Using std::shared_ptr instead of std::unique_ptr in stream data entry
Change-Id: Ib8c6f97c2329ba5b9431c301d85c1d61f89fc3d8
This commit is contained in:
parent
9990524f98
commit
5f6e4a1dc1
|
@ -44,12 +44,12 @@ struct StreamData {
|
|||
int stream_index = -1;
|
||||
StreamDataType stream_data_type = StreamDataType::kUnknown;
|
||||
|
||||
std::unique_ptr<PeriodInfo> period_info;
|
||||
std::unique_ptr<StreamInfo> stream_info;
|
||||
std::unique_ptr<EncryptionConfig> encryption_config;
|
||||
std::unique_ptr<MediaSample> media_sample;
|
||||
std::unique_ptr<MediaEvent> media_event;
|
||||
std::unique_ptr<SegmentInfo> segment_info;
|
||||
std::shared_ptr<PeriodInfo> period_info;
|
||||
std::shared_ptr<StreamInfo> stream_info;
|
||||
std::shared_ptr<EncryptionConfig> encryption_config;
|
||||
std::shared_ptr<MediaSample> media_sample;
|
||||
std::shared_ptr<MediaEvent> media_event;
|
||||
std::shared_ptr<SegmentInfo> 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<PeriodInfo> period_info) {
|
||||
std::shared_ptr<PeriodInfo> period_info) {
|
||||
std::unique_ptr<StreamData> 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<StreamInfo> stream_info) {
|
||||
std::shared_ptr<StreamInfo> stream_info) {
|
||||
std::unique_ptr<StreamData> 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<MediaSample> media_sample) {
|
||||
std::shared_ptr<MediaSample> media_sample) {
|
||||
std::unique_ptr<StreamData> 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<MediaEvent> media_event) {
|
||||
std::shared_ptr<MediaEvent> media_event) {
|
||||
std::unique_ptr<StreamData> 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<SegmentInfo> segment_info) {
|
||||
std::shared_ptr<SegmentInfo> segment_info) {
|
||||
std::unique_ptr<StreamData> stream_data(new StreamData);
|
||||
stream_data->stream_index = stream_index;
|
||||
stream_data->stream_data_type = StreamDataType::kSegmentInfo;
|
||||
|
|
|
@ -133,16 +133,17 @@ void MediaHandlerTestBase::ClearOutputStreamDataVector() {
|
|||
next_handler_->clear_stream_data_vector();
|
||||
}
|
||||
|
||||
std::unique_ptr<StreamInfo> MediaHandlerTestBase::GetMockStreamInfo(
|
||||
Codec codec, uint32_t time_scale) {
|
||||
std::shared_ptr<StreamInfo> MediaHandlerTestBase::GetMockStreamInfo(
|
||||
Codec codec,
|
||||
uint32_t time_scale) {
|
||||
if (codec >= kCodecAudio && codec < kCodecAudioMaxPlusOne) {
|
||||
return std::unique_ptr<StreamInfo>(new AudioStreamInfo(
|
||||
return std::shared_ptr<StreamInfo>(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<StreamInfo>(new VideoStreamInfo(
|
||||
return std::shared_ptr<StreamInfo>(new VideoStreamInfo(
|
||||
kTrackId, time_scale, kDuration, codec, kCodecString, kCodecConfig,
|
||||
sizeof(kCodecConfig), kWidth, kHeight, kPixelWidth, kPixelHeight,
|
||||
kTrickPlayRate, kNaluLengthSize, kLanguage, !kEncrypted));
|
||||
|
|
|
@ -85,7 +85,7 @@ class MediaHandlerTestBase : public ::testing::Test {
|
|||
MediaHandlerTestBase& operator=(const MediaHandlerTestBase&) = delete;
|
||||
|
||||
// Get a mock stream info for testing.
|
||||
std::unique_ptr<StreamInfo> GetMockStreamInfo(Codec codec,
|
||||
std::shared_ptr<StreamInfo> GetMockStreamInfo(Codec codec,
|
||||
uint32_t time_scale);
|
||||
|
||||
// Downstream handler used in testing graph.
|
||||
|
|
|
@ -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<std::unique_ptr<SegmentInfo>> segment_info_;
|
||||
std::vector<std::unique_ptr<SegmentInfo>> subsegment_info_;
|
||||
std::vector<std::shared_ptr<SegmentInfo>> segment_info_;
|
||||
std::vector<std::shared_ptr<SegmentInfo>> subsegment_info_;
|
||||
std::vector<uint32_t> time_scales_;
|
||||
// The end timestamp of the last dispatched sample.
|
||||
std::vector<int64_t> last_sample_end_timestamps_;
|
||||
|
|
Loading…
Reference in New Issue