Replace scoped_refptr with std::shared_ptr

Change-Id: Ie8ea66e78c42c7387a97bb1abc331c636be11aa4
This commit is contained in:
Kongqun Yang 2017-01-23 16:55:02 -08:00 committed by KongQun Yang
parent 24b0e3031a
commit 97fbaaa567
85 changed files with 378 additions and 424 deletions

View File

@ -27,6 +27,8 @@ class AudioStreamInfo : public StreamInfo {
uint32_t avg_bitrate, const std::string& language,
bool is_encrypted);
~AudioStreamInfo() override;
/// @name StreamInfo implementation overrides.
/// @{
bool IsValidConfig() const override;
@ -54,8 +56,6 @@ class AudioStreamInfo : public StreamInfo {
static std::string GetCodecString(Codec codec, uint8_t audio_object_type);
private:
~AudioStreamInfo() override;
uint8_t sample_bits_;
uint8_t num_channels_;
uint32_t sampling_frequency_;

View File

@ -119,19 +119,19 @@ Status Demuxer::Initialize() {
}
void Demuxer::ParserInitEvent(
const std::vector<scoped_refptr<StreamInfo>>& stream_infos) {
const std::vector<std::shared_ptr<StreamInfo>>& stream_infos) {
init_event_received_ = true;
for (const scoped_refptr<StreamInfo>& stream_info : stream_infos)
for (const std::shared_ptr<StreamInfo>& stream_info : stream_infos)
streams_.emplace_back(new MediaStream(stream_info, this));
}
Demuxer::QueuedSample::QueuedSample(uint32_t local_track_id,
scoped_refptr<MediaSample> local_sample)
std::shared_ptr<MediaSample> local_sample)
: track_id(local_track_id), sample(local_sample) {}
Demuxer::QueuedSample::~QueuedSample() {}
bool Demuxer::NewSampleEvent(uint32_t track_id,
const scoped_refptr<MediaSample>& sample) {
const std::shared_ptr<MediaSample>& sample) {
if (!init_event_received_) {
if (queued_samples_.size() >= kQueuedSamplesLimit) {
LOG(ERROR) << "Queued samples limit reached: " << kQueuedSamplesLimit;
@ -151,7 +151,7 @@ bool Demuxer::NewSampleEvent(uint32_t track_id,
}
bool Demuxer::PushSample(uint32_t track_id,
const scoped_refptr<MediaSample>& sample) {
const std::shared_ptr<MediaSample>& sample) {
for (const std::unique_ptr<MediaStream>& stream : streams_) {
if (track_id == stream->info()->track_id()) {
Status status = stream->PushSample(sample);
@ -184,7 +184,7 @@ Status Demuxer::Run() {
if (status.error_code() == error::END_OF_STREAM) {
// Push EOS sample to muxer to indicate end of stream.
const scoped_refptr<MediaSample>& sample = MediaSample::CreateEOSBuffer();
const std::shared_ptr<MediaSample>& sample = MediaSample::CreateEOSBuffer();
for (const std::unique_ptr<MediaStream>& stream : streams_) {
status = stream->PushSample(sample);
if (!status.ok())

View File

@ -12,7 +12,6 @@
#include <vector>
#include "packager/base/compiler_specific.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/container_names.h"
#include "packager/media/base/status.h"
@ -74,23 +73,27 @@ class Demuxer {
MediaContainerName container_name() { return container_name_; }
private:
Demuxer(const Demuxer&) = delete;
Demuxer& operator=(const Demuxer&) = delete;
struct QueuedSample {
QueuedSample(uint32_t track_id, scoped_refptr<MediaSample> sample);
QueuedSample(uint32_t track_id, std::shared_ptr<MediaSample> sample);
~QueuedSample();
uint32_t track_id;
scoped_refptr<MediaSample> sample;
std::shared_ptr<MediaSample> sample;
};
// Parser init event.
void ParserInitEvent(const std::vector<scoped_refptr<StreamInfo> >& streams);
void ParserInitEvent(const std::vector<std::shared_ptr<StreamInfo>>& streams);
// Parser new sample event handler. Queues the samples if init event has not
// been received, otherwise calls PushSample() to push the sample to
// corresponding stream.
bool NewSampleEvent(uint32_t track_id,
const scoped_refptr<MediaSample>& sample);
const std::shared_ptr<MediaSample>& sample);
// Helper function to push the sample to corresponding stream.
bool PushSample(uint32_t track_id, const scoped_refptr<MediaSample>& sample);
bool PushSample(uint32_t track_id,
const std::shared_ptr<MediaSample>& sample);
std::string file_name_;
File* media_file_;
@ -104,8 +107,6 @@ class Demuxer {
std::unique_ptr<uint8_t[]> buffer_;
std::unique_ptr<KeySource> key_source_;
bool cancelled_;
DISALLOW_COPY_AND_ASSIGN(Demuxer);
};
} // namespace media

View File

@ -12,7 +12,6 @@
#include <vector>
#include "packager/base/callback.h"
#include "packager/base/compiler_specific.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/container_names.h"
namespace shaka {
@ -30,8 +29,9 @@ class MediaParser {
/// Called upon completion of parser initialization.
/// @param stream_info contains the stream info of all the elementary streams
/// within this file.
typedef base::Callback<
void(const std::vector<scoped_refptr<StreamInfo> >& stream_info)> InitCB;
typedef base::Callback<void(
const std::vector<std::shared_ptr<StreamInfo> >& stream_info)>
InitCB;
/// Called when a new media sample has been parsed.
/// @param track_id is the track id of the new sample.
@ -39,7 +39,7 @@ class MediaParser {
/// @return true if the sample is accepted, false if something was wrong
/// with the sample and a parsing error should be signaled.
typedef base::Callback<bool(uint32_t track_id,
const scoped_refptr<MediaSample>& media_sample)>
const std::shared_ptr<MediaSample>& media_sample)>
NewSampleCB;
/// Initialize the parser with necessary callbacks. Must be called before any

View File

@ -42,43 +42,42 @@ MediaSample::MediaSample() : dts_(0),
MediaSample::~MediaSample() {}
// static
scoped_refptr<MediaSample> MediaSample::CopyFrom(const uint8_t* data,
std::shared_ptr<MediaSample> MediaSample::CopyFrom(const uint8_t* data,
size_t data_size,
bool is_key_frame) {
// If you hit this CHECK you likely have a bug in a demuxer. Go fix it.
CHECK(data);
return make_scoped_refptr(
new MediaSample(data, data_size, NULL, 0u, is_key_frame));
return std::make_shared<MediaSample>(data, data_size, nullptr, 0u,
is_key_frame);
}
// static
scoped_refptr<MediaSample> MediaSample::CopyFrom(const uint8_t* data,
std::shared_ptr<MediaSample> MediaSample::CopyFrom(const uint8_t* data,
size_t data_size,
const uint8_t* side_data,
size_t side_data_size,
bool is_key_frame) {
// If you hit this CHECK you likely have a bug in a demuxer. Go fix it.
CHECK(data);
return make_scoped_refptr(new MediaSample(
data, data_size, side_data, side_data_size, is_key_frame));
return std::make_shared<MediaSample>(data, data_size, side_data,
side_data_size, is_key_frame);
}
// static
scoped_refptr<MediaSample> MediaSample::FromMetadata(const uint8_t* metadata,
std::shared_ptr<MediaSample> MediaSample::FromMetadata(const uint8_t* metadata,
size_t metadata_size) {
return make_scoped_refptr(
new MediaSample(nullptr, 0, metadata, metadata_size, false));
return std::make_shared<MediaSample>(nullptr, 0, metadata, metadata_size,
false);
}
// static
scoped_refptr<MediaSample> MediaSample::CreateEmptyMediaSample() {
MediaSample* media_sample = new MediaSample();
return make_scoped_refptr(media_sample);
std::shared_ptr<MediaSample> MediaSample::CreateEmptyMediaSample() {
return std::make_shared<MediaSample>();
}
// static
scoped_refptr<MediaSample> MediaSample::CreateEOSBuffer() {
return make_scoped_refptr(new MediaSample(NULL, 0, NULL, 0, false));
std::shared_ptr<MediaSample> MediaSample::CreateEOSBuffer() {
return std::make_shared<MediaSample>(nullptr, 0, nullptr, 0, false);
}
std::string MediaSample::ToString() const {

View File

@ -8,25 +8,25 @@
#define MEDIA_BASE_MEDIA_SAMPLE_H_
#include <deque>
#include <memory>
#include <string>
#include <vector>
#include "packager/base/logging.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/decrypt_config.h"
namespace shaka {
namespace media {
/// Class to hold a media sample.
class MediaSample : public base::RefCountedThreadSafe<MediaSample> {
class MediaSample {
public:
/// Create a MediaSample object from input.
/// @param data points to the buffer containing the sample data.
/// Must not be NULL.
/// @param size indicates sample size in bytes. Must not be negative.
/// @param is_key_frame indicates whether the sample is a key frame.
static scoped_refptr<MediaSample> CopyFrom(const uint8_t* data,
static std::shared_ptr<MediaSample> CopyFrom(const uint8_t* data,
size_t size,
bool is_key_frame);
@ -39,7 +39,7 @@ class MediaSample : public base::RefCountedThreadSafe<MediaSample> {
/// @param size indicates sample size in bytes. Must not be negative.
/// @param side_data_size indicates additional sample data size in bytes.
/// @param is_key_frame indicates whether the sample is a key frame.
static scoped_refptr<MediaSample> CopyFrom(const uint8_t* data,
static std::shared_ptr<MediaSample> CopyFrom(const uint8_t* data,
size_t size,
const uint8_t* side_data,
size_t side_data_size,
@ -51,16 +51,27 @@ class MediaSample : public base::RefCountedThreadSafe<MediaSample> {
/// @param metadata points to the buffer containing metadata.
/// Must not be NULL.
/// @param metadata_size is the size of metadata in bytes.
static scoped_refptr<MediaSample> FromMetadata(const uint8_t* metadata,
static std::shared_ptr<MediaSample> FromMetadata(const uint8_t* metadata,
size_t metadata_size);
/// Create a MediaSample object with default members.
static scoped_refptr<MediaSample> CreateEmptyMediaSample();
static std::shared_ptr<MediaSample> CreateEmptyMediaSample();
/// Create a MediaSample indicating we've reached end of stream.
/// Calling any method other than end_of_stream() on the resulting buffer
/// is disallowed.
static scoped_refptr<MediaSample> CreateEOSBuffer();
static std::shared_ptr<MediaSample> CreateEOSBuffer();
// Create a MediaSample. Buffer will be padded and aligned as necessary.
// |data|,|side_data| can be NULL, which indicates an empty sample.
// |size|,|side_data_size| should not be negative.
MediaSample(const uint8_t* data,
size_t size,
const uint8_t* side_data,
size_t side_data_size,
bool is_key_frame);
MediaSample();
virtual ~MediaSample();
int64_t dts() const {
DCHECK(!end_of_stream());
@ -154,19 +165,6 @@ class MediaSample : public base::RefCountedThreadSafe<MediaSample> {
std::string ToString() const;
private:
friend class base::RefCountedThreadSafe<MediaSample>;
// Create a MediaSample. Buffer will be padded and aligned as necessary.
// |data|,|side_data| can be NULL, which indicates an empty sample.
// |size|,|side_data_size| should not be negative.
MediaSample(const uint8_t* data,
size_t size,
const uint8_t* side_data,
size_t side_data_size,
bool is_key_frame);
MediaSample();
virtual ~MediaSample();
// Decoding time stamp.
int64_t dts_;
// Presentation time stamp.
@ -193,7 +191,7 @@ class MediaSample : public base::RefCountedThreadSafe<MediaSample> {
DISALLOW_COPY_AND_ASSIGN(MediaSample);
};
typedef std::deque<scoped_refptr<MediaSample> > BufferQueue;
typedef std::deque<std::shared_ptr<MediaSample>> BufferQueue;
} // namespace media
} // namespace shaka

View File

@ -16,12 +16,12 @@
namespace shaka {
namespace media {
MediaStream::MediaStream(scoped_refptr<StreamInfo> info, Demuxer* demuxer)
MediaStream::MediaStream(std::shared_ptr<StreamInfo> info, Demuxer* demuxer)
: info_(info), demuxer_(demuxer), muxer_(NULL), state_(kIdle) {}
MediaStream::~MediaStream() {}
Status MediaStream::PullSample(scoped_refptr<MediaSample>* sample) {
Status MediaStream::PullSample(std::shared_ptr<MediaSample>* sample) {
DCHECK(state_ == kPulling || state_ == kIdle);
// Trigger a new parse in demuxer if no more samples.
@ -36,7 +36,7 @@ Status MediaStream::PullSample(scoped_refptr<MediaSample>* sample) {
return Status::OK;
}
Status MediaStream::PushSample(const scoped_refptr<MediaSample>& sample) {
Status MediaStream::PushSample(const std::shared_ptr<MediaSample>& sample) {
switch (state_) {
case kIdle:
case kPulling:
@ -98,7 +98,9 @@ Status MediaStream::Start(MediaStreamOperation operation) {
}
}
const scoped_refptr<StreamInfo> MediaStream::info() const { return info_; }
const std::shared_ptr<StreamInfo> MediaStream::info() const {
return info_;
}
std::string MediaStream::ToString() const {
return base::StringPrintf("state: %d\n samples in the queue: %zu\n %s",

View File

@ -10,7 +10,6 @@
#include <deque>
#include <memory>
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/status.h"
namespace shaka {
@ -31,7 +30,7 @@ class MediaStream {
};
/// Create MediaStream from StreamInfo and Demuxer.
/// @param demuxer cannot be NULL.
MediaStream(scoped_refptr<StreamInfo> info, Demuxer* demuxer);
MediaStream(std::shared_ptr<StreamInfo> info, Demuxer* demuxer);
~MediaStream();
/// Connect the stream to Muxer.
@ -42,19 +41,22 @@ class MediaStream {
Status Start(MediaStreamOperation operation);
/// Push sample to Muxer (triggered by Demuxer).
Status PushSample(const scoped_refptr<MediaSample>& sample);
Status PushSample(const std::shared_ptr<MediaSample>& sample);
/// Pull sample from Demuxer (triggered by Muxer).
Status PullSample(scoped_refptr<MediaSample>* sample);
Status PullSample(std::shared_ptr<MediaSample>* sample);
Demuxer* demuxer() { return demuxer_; }
Muxer* muxer() { return muxer_; }
const scoped_refptr<StreamInfo> info() const;
const std::shared_ptr<StreamInfo> info() const;
/// @return a human-readable string describing |*this|.
std::string ToString() const;
private:
MediaStream(const MediaStream&) = delete;
MediaStream& operator=(const MediaStream&) = delete;
// State transition diagram available @ http://goo.gl/ThJQbl.
enum State {
kIdle,
@ -64,14 +66,12 @@ class MediaStream {
kPulling,
};
scoped_refptr<StreamInfo> info_;
std::shared_ptr<StreamInfo> info_;
Demuxer* demuxer_;
Muxer* muxer_;
State state_;
// An internal buffer to store samples temporarily.
std::deque<scoped_refptr<MediaSample> > samples_;
DISALLOW_COPY_AND_ASSIGN(MediaStream);
std::deque<std::shared_ptr<MediaSample>> samples_;
};
} // namespace media

View File

@ -71,7 +71,7 @@ Status Muxer::Run() {
if (cancelled_)
return Status(error::CANCELLED, "muxer run cancelled");
scoped_refptr<MediaSample> sample;
std::shared_ptr<MediaSample> sample;
status = streams_[current_stream_id]->PullSample(&sample);
if (!status.ok())
break;
@ -101,7 +101,7 @@ void Muxer::SetProgressListener(
}
Status Muxer::AddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) {
std::shared_ptr<MediaSample> sample) {
DCHECK(std::find(streams_.begin(), streams_.end(), stream) != streams_.end());
if (!initialized_) {

View File

@ -12,7 +12,6 @@
#include <memory>
#include <vector>
#include "packager/base/memory/ref_counted.h"
#include "packager/base/time/clock.h"
#include "packager/media/base/fourccs.h"
#include "packager/media/base/muxer_options.h"
@ -118,7 +117,7 @@ class Muxer {
// Add new media sample.
Status AddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample);
std::shared_ptr<MediaSample> sample);
// Initialize the muxer.
virtual Status Initialize() = 0;
@ -128,7 +127,7 @@ class Muxer {
// AddSample implementation.
virtual Status DoAddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) = 0;
std::shared_ptr<MediaSample> sample) = 0;
MuxerOptions options_;
bool initialized_;

View File

@ -10,8 +10,6 @@
#include <string>
#include <vector>
#include "packager/base/memory/ref_counted.h"
namespace shaka {
namespace media {
@ -50,13 +48,15 @@ enum Codec {
};
/// Abstract class holds stream information.
class StreamInfo : public base::RefCountedThreadSafe<StreamInfo> {
class StreamInfo {
public:
StreamInfo(StreamType stream_type, int track_id, uint32_t time_scale,
uint64_t duration, Codec codec, const std::string& codec_string,
const uint8_t* codec_config, size_t codec_config_size,
const std::string& language, bool is_encrypted);
virtual ~StreamInfo();
/// @return true if this object has appropriate configuration values, false
/// otherwise.
virtual bool IsValidConfig() const = 0;
@ -82,10 +82,6 @@ class StreamInfo : public base::RefCountedThreadSafe<StreamInfo> {
}
void set_language(const std::string& language) { language_ = language; }
protected:
friend class base::RefCountedThreadSafe<StreamInfo>;
virtual ~StreamInfo();
private:
// Whether the stream is Audio or Video.
StreamType stream_type_;

View File

@ -32,14 +32,13 @@ class TextStreamInfo : public StreamInfo {
const std::string& codec_config, uint16_t width,
uint16_t height, const std::string& language);
~TextStreamInfo() override;
bool IsValidConfig() const override;
uint16_t width() const { return width_; }
uint16_t height() const { return height_; }
protected:
~TextStreamInfo() override;
private:
uint16_t width_;
uint16_t height_;

View File

@ -26,6 +26,8 @@ class VideoStreamInfo : public StreamInfo {
uint8_t nalu_length_size, const std::string& language,
bool is_encrypted);
~VideoStreamInfo() override;
/// @name StreamInfo implementation overrides.
/// @{
bool IsValidConfig() const override;
@ -54,8 +56,6 @@ class VideoStreamInfo : public StreamInfo {
}
private:
~VideoStreamInfo() override;
uint16_t width_;
uint16_t height_;

View File

@ -12,7 +12,6 @@
#include "packager/base/bind.h"
#include "packager/base/json/json_reader.h"
#include "packager/base/json/json_writer.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/fixed_key_source.h"
#include "packager/media/base/http_key_fetcher.h"
#include "packager/media/base/producer_consumer_queue.h"
@ -110,27 +109,6 @@ bool GetPsshDataFromTrack(const base::DictionaryValue& track_dict,
namespace media {
// A ref counted wrapper for EncryptionKeyMap.
class WidevineKeySource::RefCountedEncryptionKeyMap
: public base::RefCountedThreadSafe<RefCountedEncryptionKeyMap> {
public:
explicit RefCountedEncryptionKeyMap(EncryptionKeyMap* encryption_key_map) {
DCHECK(encryption_key_map);
encryption_key_map_.swap(*encryption_key_map);
}
const EncryptionKeyMap& map() { return encryption_key_map_; }
private:
friend class base::RefCountedThreadSafe<RefCountedEncryptionKeyMap>;
~RefCountedEncryptionKeyMap() {}
EncryptionKeyMap encryption_key_map_;
DISALLOW_COPY_AND_ASSIGN(RefCountedEncryptionKeyMap);
};
WidevineKeySource::WidevineKeySource(const std::string& server_url,
bool add_common_pssh)
: key_production_thread_("KeyProductionThread",
@ -288,9 +266,8 @@ Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index,
DCHECK_LE(track_type, NUM_VALID_TRACK_TYPES);
DCHECK_NE(track_type, TRACK_TYPE_UNKNOWN);
scoped_refptr<RefCountedEncryptionKeyMap> ref_counted_encryption_key_map;
Status status =
key_pool_->Peek(crypto_period_index, &ref_counted_encryption_key_map,
std::shared_ptr<EncryptionKeyMap> encryption_key_map;
Status status = key_pool_->Peek(crypto_period_index, &encryption_key_map,
kGetKeyTimeoutInSeconds * 1000);
if (!status.ok()) {
if (status.error_code() == error::STOPPED) {
@ -300,13 +277,11 @@ Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index,
return status;
}
const EncryptionKeyMap& encryption_key_map =
ref_counted_encryption_key_map->map();
if (encryption_key_map.find(track_type) == encryption_key_map.end()) {
if (encryption_key_map->find(track_type) == encryption_key_map->end()) {
return Status(error::INTERNAL_ERROR,
"Cannot find key of type " + TrackTypeToString(track_type));
}
*key = *encryption_key_map.at(track_type);
*key = *encryption_key_map->at(track_type);
return Status::OK;
}
@ -601,11 +576,9 @@ bool WidevineKeySource::PushToKeyPool(
EncryptionKeyMap* encryption_key_map) {
DCHECK(key_pool_);
DCHECK(encryption_key_map);
Status status =
key_pool_->Push(scoped_refptr<RefCountedEncryptionKeyMap>(
new RefCountedEncryptionKeyMap(encryption_key_map)),
kInfiniteTimeout);
encryption_key_map->clear();
auto encryption_key_map_shared = std::make_shared<EncryptionKeyMap>();
encryption_key_map_shared->swap(*encryption_key_map);
Status status = key_pool_->Push(encryption_key_map_shared, kInfiniteTimeout);
if (!status.ok()) {
DCHECK_EQ(error::STOPPED, status.error_code());
return false;

View File

@ -68,8 +68,7 @@ class WidevineKeySource : public KeySource {
private:
typedef std::map<TrackType, std::unique_ptr<EncryptionKey>> EncryptionKeyMap;
class RefCountedEncryptionKeyMap;
typedef ProducerConsumerQueue<scoped_refptr<RefCountedEncryptionKeyMap> >
typedef ProducerConsumerQueue<std::shared_ptr<EncryptionKeyMap>>
EncryptionKeyQueue;
// Internal routine for getting keys.

View File

@ -21,9 +21,9 @@ class BufferWriter;
/// A base class that is used to convert H.26x byte streams to NAL unit streams.
class H26xByteToUnitStreamConverter {
public:
static const size_t kUnitStreamNaluLengthSize = 4;
static constexpr size_t kUnitStreamNaluLengthSize = 4;
H26xByteToUnitStreamConverter(Nalu::CodecType type);
explicit H26xByteToUnitStreamConverter(Nalu::CodecType type);
virtual ~H26xByteToUnitStreamConverter();
/// Converts a whole byte stream encoded video frame to NAL unit stream
@ -61,4 +61,3 @@ class H26xByteToUnitStreamConverter {
} // namespace shaka
#endif // MEDIA_CODECS_H26x_BYTE_TO_UNIT_STREAM_CONVERTER_H_

View File

@ -11,7 +11,6 @@
#include <vector>
#include "packager/base/macros.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/decrypt_config.h"
namespace shaka {

View File

@ -106,7 +106,7 @@ TEST_F(HlsNotifyMuxerListenerTest, OnEncryptionInfoReadyBeforeMediaStart) {
TEST_F(HlsNotifyMuxerListenerTest, OnMediaStart) {
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
EXPECT_CALL(mock_notifier_,
@ -143,7 +143,7 @@ TEST_F(HlsNotifyMuxerListenerTest, OnEncryptionStart) {
ON_CALL(mock_notifier_, NotifyNewStream(_, _, _, _, _))
.WillByDefault(Return(true));
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
MuxerOptions muxer_options;
@ -183,7 +183,7 @@ TEST_F(HlsNotifyMuxerListenerTest, OnEncryptionStartBeforeMediaStart) {
ON_CALL(mock_notifier_, NotifyNewStream(_, _, _, _, _))
.WillByDefault(Return(true));
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
MuxerOptions muxer_options;
@ -222,7 +222,7 @@ TEST_F(HlsNotifyMuxerListenerTest, NoEncryptionUpdateIfNotifyNewStreamFails) {
EXPECT_CALL(mock_notifier_, NotifyNewStream(_, _, _, _, _))
.WillOnce(Return(false));
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
MuxerOptions muxer_options;
@ -237,7 +237,7 @@ TEST_F(HlsNotifyMuxerListenerTest, OnEncryptionInfoReady) {
ON_CALL(mock_notifier_, NotifyNewStream(_, _, _, _, _))
.WillByDefault(Return(true));
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
MuxerOptions muxer_options;
listener_.OnMediaStart(muxer_options, *video_stream_info, 90000,

View File

@ -111,7 +111,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodClearContent) {
MuxerOptions muxer_options;
SetDefaultMuxerOptionsValues(&muxer_options);
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
EXPECT_CALL(*notifier_, NotifyNewContainer(_, _)).Times(0);
@ -156,7 +156,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodEncryptedContent) {
MuxerOptions muxer_options;
SetDefaultMuxerOptionsValues(&muxer_options);
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
const std::vector<uint8_t> default_key_id(
@ -199,7 +199,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnSampleDurationReady) {
MuxerOptions muxer_options;
SetDefaultMuxerOptionsValues(&muxer_options);
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
const uint32_t kSampleDuration = 1234u;
const char kExpectedMediaInfo[] =
@ -246,7 +246,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnNewSegment) {
MuxerOptions muxer_options;
SetDefaultMuxerOptionsValues(&muxer_options);
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
const uint64_t kStartTime1 = 0u;
@ -283,7 +283,7 @@ TEST_P(MpdNotifyMuxerListenerTest, LiveNoKeyRotation) {
MuxerOptions muxer_options;
SetDefaultLiveMuxerOptionsValues(&muxer_options);
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
const std::string kExpectedMediaInfo =
@ -355,7 +355,7 @@ TEST_P(MpdNotifyMuxerListenerTest, LiveWithKeyRotation) {
MuxerOptions muxer_options;
SetDefaultLiveMuxerOptionsValues(&muxer_options);
VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams();
scoped_refptr<StreamInfo> video_stream_info =
std::shared_ptr<StreamInfo> video_stream_info =
CreateVideoStreamInfo(video_params);
// Note that this media info has protected_content with default key id.

View File

@ -14,14 +14,14 @@ namespace media {
VideoStreamInfoParameters::VideoStreamInfoParameters() {}
VideoStreamInfoParameters::~VideoStreamInfoParameters() {}
scoped_refptr<StreamInfo> CreateVideoStreamInfo(
std::shared_ptr<StreamInfo> CreateVideoStreamInfo(
const VideoStreamInfoParameters& param) {
return scoped_refptr<StreamInfo>(new VideoStreamInfo(
return std::make_shared<VideoStreamInfo>(
param.track_id, param.time_scale, param.duration, param.codec,
param.codec_string, param.codec_config.data(), param.codec_config.size(),
param.width, param.height, param.pixel_width, param.pixel_height,
0, // trick_play_rate
param.nalu_length_size, param.language, param.is_encrypted));
param.nalu_length_size, param.language, param.is_encrypted);
}
VideoStreamInfoParameters GetDefaultVideoStreamInfoParams() {

View File

@ -10,7 +10,6 @@
#include <stdint.h>
#include <vector>
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/key_source.h"
#include "packager/media/base/muxer_options.h"
#include "packager/media/base/stream_info.h"
@ -85,7 +84,7 @@ struct OnMediaEndParameters {
};
// Creates StreamInfo instance from VideoStreamInfoParameters.
scoped_refptr<StreamInfo> CreateVideoStreamInfo(
std::shared_ptr<StreamInfo> CreateVideoStreamInfo(
const VideoStreamInfoParameters& param);
// Returns the "default" VideoStreamInfoParameters for testing.

View File

@ -124,7 +124,7 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test {
};
TEST_F(VodMediaInfoDumpMuxerListenerTest, UnencryptedStream_Normal) {
scoped_refptr<StreamInfo> stream_info =
std::shared_ptr<StreamInfo> stream_info =
CreateVideoStreamInfo(GetDefaultVideoStreamInfoParams());
FireOnMediaStartWithDefaultMuxerOptions(*stream_info, !kEnableEncryption);
@ -157,7 +157,7 @@ TEST_F(VodMediaInfoDumpMuxerListenerTest, UnencryptedStream_Normal) {
}
TEST_F(VodMediaInfoDumpMuxerListenerTest, EncryptedStream_Normal) {
scoped_refptr<StreamInfo> stream_info =
std::shared_ptr<StreamInfo> stream_info =
CreateVideoStreamInfo(GetDefaultVideoStreamInfoParams());
FireOnMediaStartWithDefaultMuxerOptions(*stream_info, kEnableEncryption);
OnMediaEndParameters media_end_param = GetDefaultOnMediaEndParams();
@ -204,7 +204,7 @@ TEST_F(VodMediaInfoDumpMuxerListenerTest, CheckPixelWidthAndHeightSet) {
params.pixel_width = 8;
params.pixel_height = 9;
scoped_refptr<StreamInfo> stream_info = CreateVideoStreamInfo(params);
std::shared_ptr<StreamInfo> stream_info = CreateVideoStreamInfo(params);
FireOnMediaStartWithDefaultMuxerOptions(*stream_info, !kEnableEncryption);
OnMediaEndParameters media_end_param = GetDefaultOnMediaEndParams();
FireOnMediaEndWithParams(media_end_param);

View File

@ -8,7 +8,6 @@
#include <stdint.h>
#include "packager/base/callback.h"
#include "packager/base/memory/ref_counted.h"
namespace shaka {
namespace media {
@ -20,9 +19,9 @@ namespace mp2t {
class EsParser {
public:
typedef base::Callback<void(const scoped_refptr<StreamInfo>&)>
typedef base::Callback<void(const std::shared_ptr<StreamInfo>&)>
NewStreamInfoCB;
typedef base::Callback<void(uint32_t, const scoped_refptr<MediaSample>&)>
typedef base::Callback<void(uint32_t, const std::shared_ptr<MediaSample>&)>
EmitSampleCB;
EsParser(uint32_t pid) : pid_(pid) {}

View File

@ -159,11 +159,8 @@ bool EsParserAdts::Parse(const uint8_t* buf,
// Emit an audio frame.
bool is_key_frame = true;
scoped_refptr<MediaSample> sample =
MediaSample::CopyFrom(
frame_ptr + header_size,
frame_size - header_size,
is_key_frame);
std::shared_ptr<MediaSample> sample = MediaSample::CopyFrom(
frame_ptr + header_size, frame_size - header_size, is_key_frame);
sample->set_pts(current_pts);
sample->set_dts(current_pts);
sample->set_duration(frame_duration);
@ -188,7 +185,7 @@ void EsParserAdts::Flush() {
void EsParserAdts::Reset() {
es_byte_queue_.Reset();
pts_list_.clear();
last_audio_decoder_config_ = scoped_refptr<AudioStreamInfo>();
last_audio_decoder_config_ = std::shared_ptr<AudioStreamInfo>();
}
bool EsParserAdts::UpdateAudioConfiguration(const uint8_t* adts_frame,
@ -222,13 +219,13 @@ bool EsParserAdts::UpdateAudioConfiguration(const uint8_t* adts_frame,
? std::min(2 * samples_per_second, 48000)
: samples_per_second;
last_audio_decoder_config_ = scoped_refptr<StreamInfo>(new AudioStreamInfo(
last_audio_decoder_config_ = std::make_shared<AudioStreamInfo>(
pid(), kMpeg2Timescale, kInfiniteDuration, kCodecAAC,
AudioStreamInfo::GetCodecString(kCodecAAC, adts_header.GetObjectType()),
audio_specific_config.data(), audio_specific_config.size(),
kAacSampleSizeBits, adts_header.GetNumChannels(),
extended_samples_per_second, 0 /* seek preroll */, 0 /* codec delay */,
0 /* max bitrate */, 0 /* avg bitrate */, std::string(), false));
0 /* max bitrate */, 0 /* avg bitrate */, std::string(), false);
DVLOG(1) << "Sampling frequency: " << samples_per_second;
DVLOG(1) << "Extended sampling frequency: " << extended_samples_per_second;

View File

@ -67,7 +67,7 @@ class EsParserAdts : public EsParser {
// Interpolated PTS for frames that don't have one.
std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_;
scoped_refptr<StreamInfo> last_audio_decoder_config_;
std::shared_ptr<StreamInfo> last_audio_decoder_config_;
DISALLOW_COPY_AND_ASSIGN(EsParserAdts);
};

View File

@ -36,7 +36,7 @@ EsParserH264::~EsParserH264() {}
void EsParserH264::Reset() {
DVLOG(1) << "EsParserH264::Reset";
h264_parser_.reset(new H264Parser());
last_video_decoder_config_ = scoped_refptr<StreamInfo>();
last_video_decoder_config_ = std::shared_ptr<StreamInfo>();
decoder_config_check_pending_ = false;
EsParserH26x::Reset();
}
@ -146,15 +146,16 @@ bool EsParserH264::UpdateVideoDecoderConfig(int pps_id) {
return false;
}
last_video_decoder_config_ = scoped_refptr<StreamInfo>(new VideoStreamInfo(
const uint8_t nalu_length_size =
H26xByteToUnitStreamConverter::kUnitStreamNaluLengthSize;
last_video_decoder_config_ = std::make_shared<VideoStreamInfo>(
pid(), kMpeg2Timescale, kInfiniteDuration, kCodecH264,
AVCDecoderConfigurationRecord::GetCodecString(decoder_config_record[1],
decoder_config_record[2],
decoder_config_record[3]),
decoder_config_record.data(), decoder_config_record.size(), coded_width,
coded_height, pixel_width, pixel_height, 0,
H264ByteToUnitStreamConverter::kUnitStreamNaluLengthSize, std::string(),
false));
coded_height, pixel_width, pixel_height, 0, nalu_length_size,
std::string(), false);
DVLOG(1) << "Profile IDC: " << sps->profile_idc;
DVLOG(1) << "Level IDC: " << sps->level_idc;
DVLOG(1) << "log2_max_frame_num_minus4: " << sps->log2_max_frame_num_minus4;

View File

@ -43,7 +43,7 @@ class EsParserH264 : public EsParserH26x {
// Callback to pass the stream configuration.
NewStreamInfoCB new_stream_info_cb_;
scoped_refptr<StreamInfo> last_video_decoder_config_;
std::shared_ptr<StreamInfo> last_video_decoder_config_;
bool decoder_config_check_pending_;
std::unique_ptr<H264Parser> h264_parser_;

View File

@ -124,13 +124,13 @@ class EsParserH264Test : public testing::Test {
void LoadStream(const char* filename);
void ProcessPesPackets(const std::vector<Packet>& pes_packets);
void EmitSample(uint32_t pid, const scoped_refptr<MediaSample>& sample) {
void EmitSample(uint32_t pid, const std::shared_ptr<MediaSample>& sample) {
sample_count_++;
if (sample_count_ == 1)
first_frame_is_key_frame_ = sample->is_key_frame();
}
void NewVideoConfig(const scoped_refptr<StreamInfo>& config) {
void NewVideoConfig(const std::shared_ptr<StreamInfo>& config) {
DVLOG(1) << config->ToString();
stream_map_[config->track_id()] = config;
}
@ -145,7 +145,7 @@ class EsParserH264Test : public testing::Test {
std::vector<Packet> access_units_;
protected:
typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap;
typedef std::map<int, std::shared_ptr<StreamInfo>> StreamMap;
StreamMap stream_map_;
size_t sample_count_;
bool first_frame_is_key_frame_;

View File

@ -39,7 +39,7 @@ EsParserH265::~EsParserH265() {}
void EsParserH265::Reset() {
DVLOG(1) << "EsParserH265::Reset";
h265_parser_.reset(new H265Parser());
last_video_decoder_config_ = scoped_refptr<StreamInfo>();
last_video_decoder_config_ = std::shared_ptr<StreamInfo>();
decoder_config_check_pending_ = false;
EsParserH26x::Reset();
}
@ -151,12 +151,13 @@ bool EsParserH265::UpdateVideoDecoderConfig(int pps_id) {
return false;
}
last_video_decoder_config_ = scoped_refptr<StreamInfo>(new VideoStreamInfo(
const uint8_t nalu_length_size =
H26xByteToUnitStreamConverter::kUnitStreamNaluLengthSize;
last_video_decoder_config_ = std::make_shared<VideoStreamInfo>(
pid(), kMpeg2Timescale, kInfiniteDuration, kCodecHVC1,
decoder_config.GetCodecString(kCodecHVC1), decoder_config_record.data(),
decoder_config_record.size(), coded_width, coded_height, pixel_width,
pixel_height, 0, H26xByteToUnitStreamConverter::kUnitStreamNaluLengthSize,
std::string(), false));
pixel_height, 0, nalu_length_size, std::string(), false);
// Video config notification.
new_stream_info_cb_.Run(last_video_decoder_config_);

View File

@ -46,7 +46,7 @@ class EsParserH265 : public EsParserH26x {
NewStreamInfoCB new_stream_info_cb_;
// Last video decoder config.
scoped_refptr<StreamInfo> last_video_decoder_config_;
std::shared_ptr<StreamInfo> last_video_decoder_config_;
bool decoder_config_check_pending_;
std::unique_ptr<H265Parser> h265_parser_;

View File

@ -94,7 +94,7 @@ void EsParserH26x::Flush() {
DCHECK(pending_sample_duration_);
pending_sample_->set_duration(pending_sample_duration_);
emit_sample_cb_.Run(pid(), pending_sample_);
pending_sample_ = scoped_refptr<MediaSample>();
pending_sample_ = std::shared_ptr<MediaSample>();
}
}
@ -107,7 +107,7 @@ void EsParserH26x::Reset() {
next_access_unit_position_ = 0;
current_nalu_info_.reset();
timing_desc_list_.clear();
pending_sample_ = scoped_refptr<MediaSample>();
pending_sample_ = std::shared_ptr<MediaSample>();
pending_sample_duration_ = 0;
waiting_for_key_frame_ = true;
}
@ -299,7 +299,7 @@ bool EsParserH26x::EmitFrame(int64_t access_unit_pos,
// Create the media sample, emitting always the previous sample after
// calculating its duration.
scoped_refptr<MediaSample> media_sample = MediaSample::CopyFrom(
std::shared_ptr<MediaSample> media_sample = MediaSample::CopyFrom(
converted_frame.data(), converted_frame.size(), is_key_frame);
media_sample->set_dts(current_timing_desc.dts);
media_sample->set_pts(current_timing_desc.pts);

View File

@ -126,7 +126,7 @@ class EsParserH26x : public EsParser {
std::unique_ptr<H26xByteToUnitStreamConverter> stream_converter_;
// Frame for which we do not yet have a duration.
scoped_refptr<MediaSample> pending_sample_;
std::shared_ptr<MediaSample> pending_sample_;
uint64_t pending_sample_duration_ = 0;
// Indicates whether waiting for first key frame.

View File

@ -163,7 +163,7 @@ class EsParserH26xTest : public testing::Test {
const H26xNaluType* types,
size_t types_count);
void EmitSample(uint32_t pid, const scoped_refptr<MediaSample>& sample) {
void EmitSample(uint32_t pid, const std::shared_ptr<MediaSample>& sample) {
size_t sample_id = sample_count_;
sample_count_++;
if (sample_count_ == 1)
@ -175,7 +175,7 @@ class EsParserH26xTest : public testing::Test {
EXPECT_EQ(samples_[sample_id], sample_data);
}
void NewVideoConfig(const scoped_refptr<StreamInfo>& config) {
void NewVideoConfig(const std::shared_ptr<StreamInfo>& config) {
has_stream_info_ = true;
}

View File

@ -61,8 +61,10 @@ class PidState {
PidType pid_type() const { return pid_type_; }
scoped_refptr<StreamInfo>& config() { return config_; }
void set_config(const scoped_refptr<StreamInfo>& config) { config_ = config; }
std::shared_ptr<StreamInfo>& config() { return config_; }
void set_config(const std::shared_ptr<StreamInfo>& config) {
config_ = config;
}
SampleQueue& sample_queue() { return sample_queue_; }
@ -75,7 +77,7 @@ class PidState {
bool enable_;
int continuity_counter_;
scoped_refptr<StreamInfo> config_;
std::shared_ptr<StreamInfo> config_;
SampleQueue sample_queue_;
};
@ -333,7 +335,7 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid,
}
void Mp2tMediaParser::OnNewStreamInfo(
const scoped_refptr<StreamInfo>& new_stream_info) {
const std::shared_ptr<StreamInfo>& new_stream_info) {
DCHECK(new_stream_info);
DVLOG(1) << "OnVideoConfigChanged for pid=" << new_stream_info->track_id();
@ -360,7 +362,7 @@ bool Mp2tMediaParser::FinishInitializationIfNeeded() {
if (pids_.empty())
return true;
std::vector<scoped_refptr<StreamInfo> > all_stream_info;
std::vector<std::shared_ptr<StreamInfo>> all_stream_info;
uint32_t num_es(0);
for (PidMap::const_iterator iter = pids_.begin(); iter != pids_.end();
++iter) {
@ -383,7 +385,7 @@ bool Mp2tMediaParser::FinishInitializationIfNeeded() {
void Mp2tMediaParser::OnEmitSample(
uint32_t pes_pid,
const scoped_refptr<MediaSample>& new_sample) {
const std::shared_ptr<MediaSample>& new_sample) {
DCHECK(new_sample);
DVLOG(LOG_LEVEL_ES)
<< "OnEmitSample: "

View File

@ -9,7 +9,6 @@
#include <map>
#include <memory>
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/byte_queue.h"
#include "packager/media/base/media_parser.h"
#include "packager/media/base/stream_info.h"
@ -25,7 +24,7 @@ class PidState;
class TsPacket;
class TsSection;
typedef std::deque<scoped_refptr<MediaSample> > SampleQueue;
typedef std::deque<std::shared_ptr<MediaSample>> SampleQueue;
class Mp2tMediaParser : public MediaParser {
public:
@ -56,12 +55,12 @@ class Mp2tMediaParser : public MediaParser {
// Callback invoked each time the audio/video decoder configuration is
// changed.
void OnNewStreamInfo(const scoped_refptr<StreamInfo>& new_stream_info);
void OnNewStreamInfo(const std::shared_ptr<StreamInfo>& new_stream_info);
// Callback invoked by the ES media parser
// to emit a new audio/video access unit.
void OnEmitSample(uint32_t pes_pid,
const scoped_refptr<MediaSample>& new_sample);
const std::shared_ptr<MediaSample>& new_sample);
// Invoke the initialization callback if needed.
bool FinishInitializationIfNeeded();

View File

@ -10,7 +10,6 @@
#include "packager/base/bind.h"
#include "packager/base/bind_helpers.h"
#include "packager/base/logging.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/media_sample.h"
#include "packager/media/base/stream_info.h"
#include "packager/media/base/timestamp.h"
@ -34,7 +33,7 @@ class Mp2tMediaParserTest : public testing::Test {
}
protected:
typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap;
typedef std::map<int, std::shared_ptr<StreamInfo>> StreamMap;
std::unique_ptr<Mp2tMediaParser> parser_;
StreamMap stream_map_;
@ -62,17 +61,16 @@ class Mp2tMediaParserTest : public testing::Test {
return true;
}
void OnInit(const std::vector<scoped_refptr<StreamInfo> >& stream_infos) {
void OnInit(const std::vector<std::shared_ptr<StreamInfo>>& stream_infos) {
DVLOG(1) << "OnInit: " << stream_infos.size() << " streams.";
for (std::vector<scoped_refptr<StreamInfo> >::const_iterator iter =
stream_infos.begin(); iter != stream_infos.end(); ++iter) {
DVLOG(1) << (*iter)->ToString();
stream_map_[(*iter)->track_id()] = *iter;
for (const auto& stream_info : stream_infos) {
DVLOG(1) << stream_info->ToString();
stream_map_[stream_info->track_id()] = stream_info;
}
}
bool OnNewSample(uint32_t track_id,
const scoped_refptr<MediaSample>& sample) {
const std::shared_ptr<MediaSample>& sample) {
StreamMap::const_iterator stream = stream_map_.find(track_id);
EXPECT_NE(stream_map_.end(), stream);
if (stream != stream_map_.end()) {

View File

@ -124,7 +124,7 @@ bool PesPacketGenerator::Initialize(const StreamInfo& stream_info) {
return false;
}
bool PesPacketGenerator::PushSample(scoped_refptr<MediaSample> sample) {
bool PesPacketGenerator::PushSample(std::shared_ptr<MediaSample> sample) {
if (!current_processing_pes_)
current_processing_pes_.reset(new PesPacket());

View File

@ -44,7 +44,7 @@ class PesPacketGenerator {
/// NumberOfReadyPesPackets().
/// If this returns false, the object may end up in an undefined state.
/// @return true on success, false otherwise.
virtual bool PushSample(scoped_refptr<MediaSample> sample);
virtual bool PushSample(std::shared_ptr<MediaSample> sample);
/// Sets the encryption key for encrypting samples.
/// @param encryption_key is the key that will be used to encrypt further

View File

@ -102,16 +102,16 @@ class MockAACAudioSpecificConfig : public AACAudioSpecificConfig {
MOCK_CONST_METHOD1(ConvertToADTS, bool(std::vector<uint8_t>* buffer));
};
scoped_refptr<VideoStreamInfo> CreateVideoStreamInfo(Codec codec) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> CreateVideoStreamInfo(Codec codec) {
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, codec, kCodecString, kVideoExtraData,
arraysize(kVideoExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
return stream_info;
}
scoped_refptr<AudioStreamInfo> CreateAudioStreamInfo(Codec codec) {
scoped_refptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
std::shared_ptr<AudioStreamInfo> CreateAudioStreamInfo(Codec codec) {
std::shared_ptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
kTrackId, kTimeScale, kDuration, codec, kCodecString, kAudioExtraData,
arraysize(kAudioExtraData), kSampleBits, kNumChannels, kSamplingFrequency,
kSeekPreroll, kCodecDelay, kMaxBitrate, kAverageBitrate, kLanguage,
@ -138,12 +138,12 @@ class PesPacketGeneratorTest : public ::testing::Test {
size_t input_size,
const uint8_t* expected_output,
size_t expected_output_size) {
scoped_refptr<VideoStreamInfo> stream_info(
std::shared_ptr<VideoStreamInfo> stream_info(
CreateVideoStreamInfo(kH264Codec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(input, input_size, kIsKeyFrame);
const uint32_t kPts = 12345;
const uint32_t kDts = 12300;
@ -187,15 +187,15 @@ class PesPacketGeneratorTest : public ::testing::Test {
size_t input_size,
const uint8_t* expected_output,
size_t expected_output_size) {
scoped_refptr<AudioStreamInfo> stream_info(
std::shared_ptr<AudioStreamInfo> stream_info(
CreateAudioStreamInfo(kAacCodec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
// For aac, the input from MediaSample is used. Then ADTS header is added,
// so EXPECT_CALL does not return the |input| data.
scoped_refptr<MediaSample> sample = MediaSample::CopyFrom(
input, input_size, kIsKeyFrame);
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(input, input_size, kIsKeyFrame);
std::unique_ptr<MockAACAudioSpecificConfig> mock(
new MockAACAudioSpecificConfig());
@ -223,41 +223,44 @@ class PesPacketGeneratorTest : public ::testing::Test {
};
TEST_F(PesPacketGeneratorTest, InitializeVideo) {
scoped_refptr<VideoStreamInfo> stream_info(CreateVideoStreamInfo(kH264Codec));
std::shared_ptr<VideoStreamInfo> stream_info(
CreateVideoStreamInfo(kH264Codec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
}
TEST_F(PesPacketGeneratorTest, InitializeVideoNonH264) {
scoped_refptr<VideoStreamInfo> stream_info(
std::shared_ptr<VideoStreamInfo> stream_info(
CreateVideoStreamInfo(Codec::kCodecVP9));
EXPECT_FALSE(generator_.Initialize(*stream_info));
}
TEST_F(PesPacketGeneratorTest, InitializeAudio) {
scoped_refptr<AudioStreamInfo> stream_info(CreateAudioStreamInfo(kAacCodec));
std::shared_ptr<AudioStreamInfo> stream_info(
CreateAudioStreamInfo(kAacCodec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
}
TEST_F(PesPacketGeneratorTest, InitializeAudioNonAac) {
scoped_refptr<AudioStreamInfo> stream_info(
std::shared_ptr<AudioStreamInfo> stream_info(
CreateAudioStreamInfo(Codec::kCodecOpus));
EXPECT_FALSE(generator_.Initialize(*stream_info));
}
// Text is not supported yet.
TEST_F(PesPacketGeneratorTest, InitializeTextInfo) {
scoped_refptr<TextStreamInfo> stream_info(
std::shared_ptr<TextStreamInfo> stream_info(
new TextStreamInfo(kTrackId, kTimeScale, kDuration, kCodecString,
std::string(), kWidth, kHeight, kLanguage));
EXPECT_FALSE(generator_.Initialize(*stream_info));
}
TEST_F(PesPacketGeneratorTest, AddVideoSample) {
scoped_refptr<VideoStreamInfo> stream_info(CreateVideoStreamInfo(kH264Codec));
std::shared_ptr<VideoStreamInfo> stream_info(
CreateVideoStreamInfo(kH264Codec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
const uint32_t kPts = 12345;
const uint32_t kDts = 12300;
@ -289,11 +292,12 @@ TEST_F(PesPacketGeneratorTest, AddVideoSample) {
}
TEST_F(PesPacketGeneratorTest, AddVideoSampleFailedToConvert) {
scoped_refptr<VideoStreamInfo> stream_info(CreateVideoStreamInfo(kH264Codec));
std::shared_ptr<VideoStreamInfo> stream_info(
CreateVideoStreamInfo(kH264Codec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
std::vector<uint8_t> expected_data(kAnyData, kAnyData + arraysize(kAnyData));
@ -311,11 +315,12 @@ TEST_F(PesPacketGeneratorTest, AddVideoSampleFailedToConvert) {
}
TEST_F(PesPacketGeneratorTest, AddAudioSample) {
scoped_refptr<AudioStreamInfo> stream_info(CreateAudioStreamInfo(kAacCodec));
std::shared_ptr<AudioStreamInfo> stream_info(
CreateAudioStreamInfo(kAacCodec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
std::vector<uint8_t> expected_data(kAnyData, kAnyData + arraysize(kAnyData));
@ -340,11 +345,12 @@ TEST_F(PesPacketGeneratorTest, AddAudioSample) {
}
TEST_F(PesPacketGeneratorTest, AddAudioSampleFailedToConvert) {
scoped_refptr<AudioStreamInfo> stream_info(CreateAudioStreamInfo(kAacCodec));
std::shared_ptr<AudioStreamInfo> stream_info(
CreateAudioStreamInfo(kAacCodec));
EXPECT_TRUE(generator_.Initialize(*stream_info));
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
std::unique_ptr<MockAACAudioSpecificConfig> mock(
@ -362,7 +368,7 @@ TEST_F(PesPacketGeneratorTest, AddAudioSampleFailedToConvert) {
// are scaled.
TEST_F(PesPacketGeneratorTest, TimeStampScaling) {
const uint32_t kTestTimescale = 1000;
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTestTimescale, kDuration, kH264Codec, kCodecString,
kVideoExtraData, arraysize(kVideoExtraData), kWidth, kHeight, kPixelWidth,
kPixelHeight, kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -370,7 +376,7 @@ TEST_F(PesPacketGeneratorTest, TimeStampScaling) {
EXPECT_EQ(0u, generator_.NumberOfReadyPesPackets());
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
const uint32_t kPts = 5000;
const uint32_t kDts = 4000;

View File

@ -36,7 +36,7 @@ Status TsMuxer::Finalize() {
}
Status TsMuxer::DoAddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) {
std::shared_ptr<MediaSample> sample) {
return segmenter_->AddSample(sample);
}

View File

@ -27,7 +27,7 @@ class TsMuxer : public Muxer {
Status Initialize() override;
Status Finalize() override;
Status DoAddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) override;
std::shared_ptr<MediaSample> sample) override;
void FireOnMediaStartEvent();
void FireOnMediaEndEvent();

View File

@ -88,7 +88,7 @@ Status TsSegmenter::Finalize() {
// First checks whether the sample is a key frame. If so and the segment has
// passed the segment duration, then flush the generator and write all the data
// to file.
Status TsSegmenter::AddSample(scoped_refptr<MediaSample> sample) {
Status TsSegmenter::AddSample(std::shared_ptr<MediaSample> sample) {
const bool passed_segment_duration =
current_segment_total_sample_duration_ > muxer_options_.segment_duration;
if (sample->is_key_frame() && passed_segment_duration) {

View File

@ -53,7 +53,7 @@ class TsSegmenter {
/// @param sample gets added to this object.
/// @return OK on success.
Status AddSample(scoped_refptr<MediaSample> sample);
Status AddSample(std::shared_ptr<MediaSample> sample);
/// Only for testing.
void InjectTsWriterForTesting(std::unique_ptr<TsWriter> writer);

View File

@ -53,7 +53,7 @@ const uint8_t kAnyData[] = {
class MockPesPacketGenerator : public PesPacketGenerator {
public:
MOCK_METHOD1(Initialize, bool(const StreamInfo& info));
MOCK_METHOD1(PushSample, bool(scoped_refptr<MediaSample> sample));
MOCK_METHOD1(PushSample, bool(std::shared_ptr<MediaSample> sample));
MOCK_METHOD1(SetEncryptionKeyMock, bool(EncryptionKey* encryption_key));
bool SetEncryptionKey(
std::unique_ptr<EncryptionKey> encryption_key) override {
@ -108,7 +108,7 @@ class TsSegmenterTest : public ::testing::Test {
};
TEST_F(TsSegmenterTest, Initialize) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -128,7 +128,7 @@ TEST_F(TsSegmenterTest, Initialize) {
}
TEST_F(TsSegmenterTest, AddSample) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -141,7 +141,7 @@ TEST_F(TsSegmenterTest, AddSample) {
EXPECT_CALL(*mock_pes_packet_generator_, Initialize(_))
.WillOnce(Return(true));
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
Sequence writer_sequence;
@ -183,7 +183,7 @@ TEST_F(TsSegmenterTest, PassedSegmentDuration) {
// Use something significantly smaller than 90000 to check that the scaling is
// done correctly in the segmenter.
const uint32_t kInputTimescale = 1001;
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kInputTimescale, kDuration, kH264Codec, kCodecString,
kExtraData, arraysize(kExtraData), kWidth, kHeight, kPixelWidth,
kPixelHeight, kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -200,9 +200,9 @@ TEST_F(TsSegmenterTest, PassedSegmentDuration) {
EXPECT_CALL(*mock_pes_packet_generator_, Initialize(_))
.WillOnce(Return(true));
scoped_refptr<MediaSample> sample1 =
std::shared_ptr<MediaSample> sample1 =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
scoped_refptr<MediaSample> sample2 =
std::shared_ptr<MediaSample> sample2 =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
// 11 seconds > 10 seconds (segment duration).
@ -282,7 +282,7 @@ TEST_F(TsSegmenterTest, PassedSegmentDuration) {
// Finalize right after Initialize(). The writer will not be initialized.
TEST_F(TsSegmenterTest, InitializeThenFinalize) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -311,7 +311,7 @@ TEST_F(TsSegmenterTest, InitializeThenFinalize) {
// The test does not really add any samples but instead simulates an initialized
// writer with a mock.
TEST_F(TsSegmenterTest, Finalize) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -340,7 +340,7 @@ TEST_F(TsSegmenterTest, Finalize) {
// Verify that it won't finish a segment if the sample is not a key frame.
TEST_F(TsSegmenterTest, SegmentOnlyBeforeKeyFrame) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -356,11 +356,11 @@ TEST_F(TsSegmenterTest, SegmentOnlyBeforeKeyFrame) {
const uint8_t kAnyData[] = {
0x01, 0x0F, 0x3C,
};
scoped_refptr<MediaSample> key_frame_sample1 =
std::shared_ptr<MediaSample> key_frame_sample1 =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
scoped_refptr<MediaSample> non_key_frame_sample =
std::shared_ptr<MediaSample> non_key_frame_sample =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), !kIsKeyFrame);
scoped_refptr<MediaSample> key_frame_sample2 =
std::shared_ptr<MediaSample> key_frame_sample2 =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
// 11 seconds > 10 seconds (segment duration).
@ -446,7 +446,7 @@ TEST_F(TsSegmenterTest, SegmentOnlyBeforeKeyFrame) {
}
TEST_F(TsSegmenterTest, WithEncryptionNoClearLead) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -489,7 +489,7 @@ TEST_F(TsSegmenterTest, WithEncryptionNoClearLead) {
// Verify that the muxer listener pointer is not used without checking that it's
// not null.
TEST_F(TsSegmenterTest, WithEncryptionNoClearLeadNoMuxerListener) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -529,7 +529,7 @@ TEST_F(TsSegmenterTest, WithEncryptionNoClearLeadNoMuxerListener) {
// Verify that encryption notification is sent to objects after clear lead.
TEST_F(TsSegmenterTest, WithEncryptionWithClearLead) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -555,9 +555,9 @@ TEST_F(TsSegmenterTest, WithEncryptionWithClearLead) {
const uint8_t kAnyData[] = {
0x01, 0x0F, 0x3C,
};
scoped_refptr<MediaSample> sample1 =
std::shared_ptr<MediaSample> sample1 =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
scoped_refptr<MediaSample> sample2 =
std::shared_ptr<MediaSample> sample2 =
MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame);
// Something longer than 1.0 (segment duration and clear lead).

View File

@ -157,7 +157,7 @@ class TsWriterTest : public ::testing::Test {
};
TEST_F(TsWriterTest, InitializeVideoH264) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -165,7 +165,7 @@ TEST_F(TsWriterTest, InitializeVideoH264) {
}
TEST_F(TsWriterTest, InitializeVideoNonH264) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, Codec::kCodecVP9, kCodecString,
kExtraData, arraysize(kExtraData), kWidth, kHeight, kPixelWidth,
kPixelHeight, kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -173,7 +173,7 @@ TEST_F(TsWriterTest, InitializeVideoNonH264) {
}
TEST_F(TsWriterTest, InitializeAudioAac) {
scoped_refptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
std::shared_ptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
kTrackId, kTimeScale, kDuration, kAacCodec, kCodecString, kExtraData,
arraysize(kExtraData), kSampleBits, kNumChannels, kSamplingFrequency,
kSeekPreroll, kCodecDelay, kMaxBitrate, kAverageBitrate, kLanguage,
@ -182,7 +182,7 @@ TEST_F(TsWriterTest, InitializeAudioAac) {
}
TEST_F(TsWriterTest, InitializeAudioNonAac) {
scoped_refptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
std::shared_ptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
kTrackId, kTimeScale, kDuration, Codec::kCodecOpus, kCodecString,
kExtraData, arraysize(kExtraData), kSampleBits, kNumChannels,
kSamplingFrequency, kSeekPreroll, kCodecDelay, kMaxBitrate,
@ -198,7 +198,7 @@ TEST_F(TsWriterTest, ClearH264Psi) {
new MockProgramMapTableWriter());
EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(WriteOnePmt());
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -252,7 +252,7 @@ TEST_F(TsWriterTest, ClearAacPmt) {
new MockProgramMapTableWriter());
EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(WriteOnePmt());
scoped_refptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
std::shared_ptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
kTrackId, kTimeScale, kDuration, kAacCodec, kCodecString,
kAacBasicProfileExtraData, arraysize(kAacBasicProfileExtraData),
kSampleBits, kNumChannels, kSamplingFrequency, kSeekPreroll, kCodecDelay,
@ -280,7 +280,7 @@ TEST_F(TsWriterTest, ClearLeadH264Pmt) {
EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_))
.WillOnce(WriteTwoPmts());
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -309,7 +309,7 @@ TEST_F(TsWriterTest, EncryptedSegmentsH264Pmt) {
EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(Return(true));
EXPECT_CALL(*mock_pmt_writer, EncryptedSegmentPmt(_)).WillOnce(WriteOnePmt());
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -340,7 +340,7 @@ TEST_F(TsWriterTest, ClearLeadAacPmt) {
EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_))
.WillOnce(WriteTwoPmts());
scoped_refptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
std::shared_ptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
kTrackId, kTimeScale, kDuration, kAacCodec, kCodecString,
kAacBasicProfileExtraData, arraysize(kAacBasicProfileExtraData),
kSampleBits, kNumChannels, kSamplingFrequency, kSeekPreroll, kCodecDelay,
@ -370,7 +370,7 @@ TEST_F(TsWriterTest, EncryptedSegmentsAacPmt) {
EXPECT_CALL(*mock_pmt_writer, ClearSegmentPmt(_)).WillOnce(Return(true));
EXPECT_CALL(*mock_pmt_writer, EncryptedSegmentPmt(_)).WillOnce(WriteOnePmt());
scoped_refptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
std::shared_ptr<AudioStreamInfo> stream_info(new AudioStreamInfo(
kTrackId, kTimeScale, kDuration, kAacCodec, kCodecString,
kAacBasicProfileExtraData, arraysize(kAacBasicProfileExtraData),
kSampleBits, kNumChannels, kSamplingFrequency, kSeekPreroll, kCodecDelay,
@ -397,7 +397,7 @@ TEST_F(TsWriterTest, EncryptedSegmentsAacPmt) {
TEST_F(TsWriterTest, AddPesPacket) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -462,7 +462,7 @@ TEST_F(TsWriterTest, AddPesPacket) {
// Verify that PES packet > 64KiB can be handled.
TEST_F(TsWriterTest, BigPesPacket) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -498,7 +498,7 @@ TEST_F(TsWriterTest, BigPesPacket) {
// Bug found in code review. It should check whether PTS is present not whether
// PTS (implicilty) cast to bool is true.
TEST_F(TsWriterTest, PesPtsZeroNoDts) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));
@ -558,7 +558,7 @@ TEST_F(TsWriterTest, PesPtsZeroNoDts) {
// Verify that TS packet with payload 183 is handled correctly, e.g.
// adaptation_field_length should be 0.
TEST_F(TsWriterTest, TsPacketPayload183Bytes) {
scoped_refptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> stream_info(new VideoStreamInfo(
kTrackId, kTimeScale, kDuration, kH264Codec, kCodecString, kExtraData,
arraysize(kExtraData), kWidth, kHeight, kPixelWidth, kPixelHeight,
kTrickPlayRate, kNaluLengthSize, kLanguage, kIsEncrypted));

View File

@ -59,7 +59,7 @@ uint8_t GetNaluLengthSize(const StreamInfo& stream_info) {
} // namespace
EncryptingFragmenter::EncryptingFragmenter(
scoped_refptr<StreamInfo> info,
std::shared_ptr<StreamInfo> info,
TrackFragment* traf,
std::unique_ptr<EncryptionKey> encryption_key,
int64_t clear_time,
@ -103,7 +103,7 @@ EncryptingFragmenter::EncryptingFragmenter(
EncryptingFragmenter::~EncryptingFragmenter() {}
Status EncryptingFragmenter::AddSample(scoped_refptr<MediaSample> sample) {
Status EncryptingFragmenter::AddSample(std::shared_ptr<MediaSample> sample) {
DCHECK(sample);
if (!fragment_initialized()) {
Status status = InitializeFragment(sample->dts());
@ -248,7 +248,8 @@ void EncryptingFragmenter::EncryptBytes(uint8_t* data, size_t size) {
CHECK(encryptor_->Crypt(data, size, data));
}
Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
Status EncryptingFragmenter::EncryptSample(
std::shared_ptr<MediaSample> sample) {
DCHECK(encryptor_);
SampleEncryptionEntry sample_encryption_entry;

View File

@ -8,7 +8,6 @@
#define MEDIA_FORMATS_MP4_ENCRYPTING_FRAGMENTER_H_
#include <memory>
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/fourccs.h"
#include "packager/media/codecs/video_slice_header_parser.h"
#include "packager/media/codecs/vpx_parser.h"
@ -38,7 +37,7 @@ class EncryptingFragmenter : public Fragmenter {
/// pattern based encryption.
/// @param skip_byte_block indicates number of unencrypted blocks (16-byte)
/// in pattern based encryption.
EncryptingFragmenter(scoped_refptr<StreamInfo> info,
EncryptingFragmenter(std::shared_ptr<StreamInfo> info,
TrackFragment* traf,
std::unique_ptr<EncryptionKey> encryption_key,
int64_t clear_time,
@ -51,7 +50,7 @@ class EncryptingFragmenter : public Fragmenter {
/// @name Fragmenter implementation overrides.
/// @{
Status AddSample(scoped_refptr<MediaSample> sample) override;
Status AddSample(std::shared_ptr<MediaSample> sample) override;
Status InitializeFragment(int64_t first_sample_dts) override;
void FinalizeFragment() override;
/// @}
@ -80,12 +79,12 @@ class EncryptingFragmenter : public Fragmenter {
private:
void EncryptBytes(uint8_t* data, size_t size);
Status EncryptSample(scoped_refptr<MediaSample> sample);
Status EncryptSample(std::shared_ptr<MediaSample> sample);
// Should we enable subsample encryption?
bool IsSubsampleEncryptionRequired();
scoped_refptr<StreamInfo> info_;
std::shared_ptr<StreamInfo> info_;
std::unique_ptr<EncryptionKey> encryption_key_;
std::unique_ptr<AesCryptor> encryptor_;
// If this stream contains AVC, subsample encryption specifies that the size

View File

@ -29,7 +29,7 @@ uint64_t GetSeekPreroll(const StreamInfo& stream_info) {
}
} // namespace
Fragmenter::Fragmenter(scoped_refptr<StreamInfo> info, TrackFragment* traf)
Fragmenter::Fragmenter(std::shared_ptr<StreamInfo> info, TrackFragment* traf)
: use_decoding_timestamp_in_timeline_(false),
traf_(traf),
seek_preroll_(GetSeekPreroll(*info)),
@ -43,7 +43,7 @@ Fragmenter::Fragmenter(scoped_refptr<StreamInfo> info, TrackFragment* traf)
Fragmenter::~Fragmenter() {}
Status Fragmenter::AddSample(scoped_refptr<MediaSample> sample) {
Status Fragmenter::AddSample(std::shared_ptr<MediaSample> sample) {
DCHECK(sample);
if (sample->duration() == 0) {
LOG(WARNING) << "Unexpected sample with zero duration @ dts "

View File

@ -11,7 +11,6 @@
#include <vector>
#include "packager/base/logging.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/status.h"
namespace shaka {
@ -32,14 +31,14 @@ class Fragmenter {
public:
/// @param info contains stream information.
/// @param traf points to a TrackFragment box.
Fragmenter(scoped_refptr<StreamInfo> info, TrackFragment* traf);
Fragmenter(std::shared_ptr<StreamInfo> info, TrackFragment* traf);
virtual ~Fragmenter();
/// Add a sample to the fragmenter.
/// @param sample points to the sample to be added.
/// @return OK on success, an error status otherwise.
virtual Status AddSample(scoped_refptr<MediaSample> sample);
virtual Status AddSample(std::shared_ptr<MediaSample> sample);
/// Initialize the fragment with default data.
/// @param first_sample_dts specifies the decoding timestamp for the first

View File

@ -18,7 +18,7 @@ const bool kInitialEncryptionInfo = true;
} // namespace
KeyRotationFragmenter::KeyRotationFragmenter(MovieFragment* moof,
scoped_refptr<StreamInfo> info,
std::shared_ptr<StreamInfo> info,
TrackFragment* traf,
KeySource* encryption_key_source,
KeySource::TrackType track_type,

View File

@ -42,7 +42,7 @@ class KeyRotationFragmenter : public EncryptingFragmenter {
/// @param muxer_listener is a pointer to MuxerListener for notifying
/// muxer related events. This may be null.
KeyRotationFragmenter(MovieFragment* moof,
scoped_refptr<StreamInfo> info,
std::shared_ptr<StreamInfo> info,
TrackFragment* traf,
KeySource* encryption_key_source,
KeySource::TrackType track_type,

View File

@ -10,7 +10,6 @@
#include "packager/base/callback.h"
#include "packager/base/callback_helpers.h"
#include "packager/base/logging.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/base/strings/string_number_conversions.h"
#include "packager/media/base/audio_stream_info.h"
#include "packager/media/base/buffer_reader.h"
@ -281,7 +280,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
RCHECK(moov_->Parse(reader));
runs_.reset();
std::vector<scoped_refptr<StreamInfo> > streams;
std::vector<std::shared_ptr<StreamInfo>> streams;
for (std::vector<Track>::const_iterator track = moov_->tracks.begin();
track != moov_->tracks.end(); ++track) {
@ -466,7 +465,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
const bool is_encrypted =
entry.sinf.info.track_encryption.default_is_protected == 1;
DVLOG(1) << "is_audio_track_encrypted_: " << is_encrypted;
streams.push_back(new AudioStreamInfo(
streams.emplace_back(new AudioStreamInfo(
track->header.track_id, timescale, duration, codec,
AudioStreamInfo::GetCodecString(codec, audio_object_type),
codec_config.data(), codec_config.size(), entry.samplesize,
@ -562,7 +561,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
const bool is_encrypted =
entry.sinf.info.track_encryption.default_is_protected == 1;
DVLOG(1) << "is_video_track_encrypted_: " << is_encrypted;
scoped_refptr<VideoStreamInfo> video_stream_info(new VideoStreamInfo(
std::shared_ptr<VideoStreamInfo> video_stream_info(new VideoStreamInfo(
track->header.track_id, timescale, duration, video_codec,
codec_string, entry.codec_configuration.data.data(),
entry.codec_configuration.data.size(), coded_width, coded_height,
@ -694,8 +693,8 @@ bool MP4MediaParser::EnqueueSample(bool* err) {
return false;
}
scoped_refptr<MediaSample> stream_sample(MediaSample::CopyFrom(
buf, runs_->sample_size(), runs_->is_keyframe()));
std::shared_ptr<MediaSample> stream_sample(
MediaSample::CopyFrom(buf, runs_->sample_size(), runs_->is_keyframe()));
if (runs_->is_encrypted()) {
std::unique_ptr<DecryptConfig> decrypt_config = runs_->GetDecryptConfig();
if (!decrypt_config) {

View File

@ -14,7 +14,6 @@
#include <vector>
#include "packager/base/callback_forward.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/decryptor_source.h"
#include "packager/media/base/media_parser.h"
#include "packager/media/base/offset_byte_queue.h"

View File

@ -46,7 +46,7 @@ class MP4MediaParserTest : public testing::Test {
}
protected:
typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap;
typedef std::map<int, std::shared_ptr<StreamInfo>> StreamMap;
StreamMap stream_map_;
std::unique_ptr<MP4MediaParser> parser_;
size_t num_streams_;
@ -71,19 +71,17 @@ class MP4MediaParserTest : public testing::Test {
return true;
}
void InitF(const std::vector<scoped_refptr<StreamInfo> >& streams) {
for (std::vector<scoped_refptr<StreamInfo> >::const_iterator iter =
streams.begin();
iter != streams.end();
++iter) {
DVLOG(2) << (*iter)->ToString();
stream_map_[(*iter)->track_id()] = *iter;
void InitF(const std::vector<std::shared_ptr<StreamInfo>>& streams) {
for (const auto& stream_info : streams) {
DVLOG(2) << stream_info->ToString();
stream_map_[stream_info->track_id()] = stream_info;
}
num_streams_ = streams.size();
num_samples_ = 0;
}
bool NewSampleF(uint32_t track_id, const scoped_refptr<MediaSample>& sample) {
bool NewSampleF(uint32_t track_id,
const std::shared_ptr<MediaSample>& sample) {
DVLOG(2) << "Track Id: " << track_id << " "
<< sample->ToString();
++num_samples_;

View File

@ -168,7 +168,7 @@ Status MP4Muxer::Finalize() {
}
Status MP4Muxer::DoAddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) {
std::shared_ptr<MediaSample> sample) {
DCHECK(segmenter_);
return segmenter_->AddSample(stream, sample);
}

View File

@ -38,7 +38,7 @@ class MP4Muxer : public Muxer {
Status Initialize() override;
Status Finalize() override;
Status DoAddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) override;
std::shared_ptr<MediaSample> sample) override;
// Generate Audio/Video Track box.
void InitializeTrak(const StreamInfo* info, Track* trak);

View File

@ -321,7 +321,7 @@ Status Segmenter::Finalize() {
}
Status Segmenter::AddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) {
std::shared_ptr<MediaSample> sample) {
// Find the fragmenter for this stream.
DCHECK(stream);
DCHECK(stream_map_.find(stream) != stream_map_.end());

View File

@ -11,7 +11,6 @@
#include <memory>
#include <vector>
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/fourccs.h"
#include "packager/media/base/status.h"
#include "packager/media/formats/mp4/box_definitions.h"
@ -91,7 +90,7 @@ class Segmenter {
/// @param sample points to the sample to be added.
/// @return OK on success, an error status otherwise.
Status AddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample);
std::shared_ptr<MediaSample> sample);
/// @return true if there is an initialization range, while setting @a offset
/// and @a size; or false if initialization range does not apply.

View File

@ -203,7 +203,7 @@ class EncrypedSegmenterTest : public SegmentTestBase {
options, info_.get(), key_source_.get(), &segmenter_));
}
scoped_refptr<StreamInfo> info_;
std::shared_ptr<StreamInfo> info_;
std::unique_ptr<webm::Segmenter> segmenter_;
std::unique_ptr<KeySource> key_source_;
};
@ -217,7 +217,7 @@ TEST_F(EncrypedSegmenterTest, BasicSupport) {
// There should be 2 segments with the first segment in clear and the second
// segment encrypted.
for (int i = 0; i < 5; i++) {
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}

View File

@ -73,7 +73,7 @@ Status Encryptor::AddTrackInfo(mkvmuxer::Track* track) {
return CreateContentEncryption(track, key_.get());
}
Status Encryptor::EncryptFrame(scoped_refptr<MediaSample> sample,
Status Encryptor::EncryptFrame(std::shared_ptr<MediaSample> sample,
bool encrypt_frame) {
DCHECK(encryptor_);

View File

@ -9,7 +9,6 @@
#include <memory>
#include "packager/base/macros.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/key_source.h"
#include "packager/media/base/status.h"
#include "packager/media/base/stream_info.h"
@ -48,8 +47,7 @@ class Encryptor {
/// Encrypt the data. This needs to be told whether the current frame will
/// be encrypted (e.g. for a clear lead).
/// @return OK on success, an error status otherwise.
Status EncryptFrame(scoped_refptr<MediaSample> sample,
bool encrypt_frame);
Status EncryptFrame(std::shared_ptr<MediaSample> sample, bool encrypt_frame);
private:
// Create the encryptor for the internal encryption key.

View File

@ -108,7 +108,7 @@ class MultiSegmentSegmenterTest : public SegmentTestBase {
return GetSegmentName(segment_template_, 0, number, 0);
}
scoped_refptr<StreamInfo> info_;
std::shared_ptr<StreamInfo> info_;
std::string segment_template_;
std::unique_ptr<webm::Segmenter> segmenter_;
};
@ -120,7 +120,7 @@ TEST_F(MultiSegmentSegmenterTest, BasicSupport) {
// Write the samples to the Segmenter.
for (int i = 0; i < 5; i++) {
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}
@ -142,7 +142,7 @@ TEST_F(MultiSegmentSegmenterTest, SplitsFilesOnSegmentDuration) {
// Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) {
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}
@ -171,7 +171,7 @@ TEST_F(MultiSegmentSegmenterTest, RespectsSegmentSAPAlign) {
// Write the samples to the Segmenter.
for (int i = 0; i < 10; i++) {
const KeyFrameFlag key_frame_flag = i == 6 ? kKeyFrame : kNotKeyFrame;
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(key_frame_flag, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}
@ -198,7 +198,7 @@ TEST_F(MultiSegmentSegmenterTest, SplitsClustersOnFragmentDuration) {
// Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) {
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}
@ -224,7 +224,7 @@ TEST_F(MultiSegmentSegmenterTest, RespectsFragmentSAPAlign) {
// Write the samples to the Segmenter.
for (int i = 0; i < 10; i++) {
const KeyFrameFlag key_frame_flag = i == 6 ? kKeyFrame : kNotKeyFrame;
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(key_frame_flag, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}

View File

@ -121,7 +121,7 @@ Status Segmenter::Finalize() {
return DoFinalize();
}
Status Segmenter::AddSample(scoped_refptr<MediaSample> sample) {
Status Segmenter::AddSample(std::shared_ptr<MediaSample> sample) {
if (sample_duration_ == 0) {
first_timestamp_ = sample->pts();
sample_duration_ = sample->duration();

View File

@ -8,7 +8,6 @@
#define MEDIA_FORMATS_WEBM_SEGMENTER_H_
#include <memory>
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/status.h"
#include "packager/media/formats/webm/encryptor.h"
#include "packager/media/formats/webm/mkv_writer.h"
@ -75,7 +74,7 @@ class Segmenter {
/// Add sample to the indicated stream.
/// @param sample points to the sample to be added.
/// @return OK on success, an error status otherwise.
Status AddSample(scoped_refptr<MediaSample> sample);
Status AddSample(std::shared_ptr<MediaSample> sample);
/// @return true if there is an initialization range, while setting @a start
/// and @a end; or false if initialization range does not apply.
@ -140,7 +139,7 @@ class Segmenter {
virtual Status NewSegment(uint64_t start_timescale) = 0;
// Store the previous sample so we know which one is the last frame.
scoped_refptr<MediaSample> prev_sample_;
std::shared_ptr<MediaSample> prev_sample_;
// The reference frame timestamp; used to populate the ReferenceBlock element
// when writing non-keyframe BlockGroups.
uint64_t reference_frame_timestamp_;

View File

@ -49,11 +49,11 @@ void SegmentTestBase::TearDown() {
MemoryFile::DeleteAll();
}
scoped_refptr<MediaSample> SegmentTestBase::CreateSample(
std::shared_ptr<MediaSample> SegmentTestBase::CreateSample(
KeyFrameFlag key_frame_flag,
uint64_t duration,
SideDataFlag side_data_flag) {
scoped_refptr<MediaSample> sample;
std::shared_ptr<MediaSample> sample;
const bool is_key_frame = key_frame_flag == kKeyFrame;
if (side_data_flag == kGenerateSideData) {
sample = MediaSample::CopyFrom(

View File

@ -62,7 +62,7 @@ class SegmentTestBase : public ::testing::Test {
}
/// Creates a new media sample.
scoped_refptr<MediaSample> CreateSample(KeyFrameFlag key_frame_flag,
std::shared_ptr<MediaSample> CreateSample(KeyFrameFlag key_frame_flag,
uint64_t duration,
SideDataFlag side_data_flag);
/// Creates a Muxer options object for testing.

View File

@ -143,7 +143,7 @@ class SingleSegmentSegmenterTest : public SegmentTestBase {
options, info_.get(), NULL, &segmenter_));
}
scoped_refptr<StreamInfo> info_;
std::shared_ptr<StreamInfo> info_;
std::unique_ptr<webm::Segmenter> segmenter_;
};
@ -155,7 +155,7 @@ TEST_F(SingleSegmentSegmenterTest, BasicSupport) {
for (int i = 0; i < 5; i++) {
const SideDataFlag side_data_flag =
i == 3 ? kGenerateSideData : kNoSideData;
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, side_data_flag);
ASSERT_OK(segmenter_->AddSample(sample));
}
@ -171,7 +171,7 @@ TEST_F(SingleSegmentSegmenterTest, SplitsClustersOnSegmentDuration) {
// Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) {
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}
@ -192,7 +192,7 @@ TEST_F(SingleSegmentSegmenterTest, IgnoresFragmentDuration) {
// Write the samples to the Segmenter.
for (int i = 0; i < 8; i++) {
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(kKeyFrame, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}
@ -214,7 +214,7 @@ TEST_F(SingleSegmentSegmenterTest, RespectsSAPAlign) {
// Write the samples to the Segmenter.
for (int i = 0; i < 10; i++) {
const KeyFrameFlag key_frame_flag = i == 6 ? kKeyFrame : kNotKeyFrame;
scoped_refptr<MediaSample> sample =
std::shared_ptr<MediaSample> sample =
CreateSample(key_frame_flag, kDuration, kNoSideData);
ASSERT_OK(segmenter_->AddSample(sample));
}

View File

@ -28,7 +28,7 @@ void WebMAudioClient::Reset() {
output_samples_per_second_ = -1;
}
scoped_refptr<AudioStreamInfo> WebMAudioClient::GetAudioStreamInfo(
std::shared_ptr<AudioStreamInfo> WebMAudioClient::GetAudioStreamInfo(
int64_t track_num,
const std::string& codec_id,
const std::vector<uint8_t>& codec_private,
@ -43,11 +43,11 @@ scoped_refptr<AudioStreamInfo> WebMAudioClient::GetAudioStreamInfo(
audio_codec = kCodecOpus;
} else {
LOG(ERROR) << "Unsupported audio codec_id " << codec_id;
return scoped_refptr<AudioStreamInfo>();
return std::shared_ptr<AudioStreamInfo>();
}
if (samples_per_second_ <= 0)
return scoped_refptr<AudioStreamInfo>();
return std::shared_ptr<AudioStreamInfo>();
// Set channel layout default if a Channels element was not present.
if (channels_ == -1)
@ -68,12 +68,12 @@ scoped_refptr<AudioStreamInfo> WebMAudioClient::GetAudioStreamInfo(
}
const uint8_t kSampleSizeInBits = 16u;
return scoped_refptr<AudioStreamInfo>(new AudioStreamInfo(
return std::make_shared<AudioStreamInfo>(
track_num, kWebMTimeScale, 0, audio_codec,
AudioStreamInfo::GetCodecString(audio_codec, 0), codec_config,
codec_config_size, kSampleSizeInBits, channels_, sampling_frequency,
seek_preroll < 0 ? 0 : seek_preroll, codec_delay < 0 ? 0 : codec_delay, 0,
0, language, is_encrypted));
0, language, is_encrypted);
}
bool WebMAudioClient::OnUInt(int id, int64_t val) {

View File

@ -37,10 +37,10 @@ class WebMAudioClient : public WebMParserClient {
/// value of 0 is used.
/// @param language indicates the language for the track.
/// @param is_encrypted indicates whether the stream is encrypted.
/// @return An AudioStreamInfo scoped_refptr if successful.
/// @return An empty scoped_refptr if there was unexpected values in the
/// @return An AudioStreamInfo if successful.
/// @return An empty pointer if there was unexpected values in the
/// provided parameters or audio track element fields.
scoped_refptr<AudioStreamInfo> GetAudioStreamInfo(
std::shared_ptr<AudioStreamInfo> GetAudioStreamInfo(
int64_t track_num,
const std::string& codec_id,
const std::vector<uint8_t>& codec_private,

View File

@ -28,8 +28,8 @@ const int64_t kMicrosecondsPerMillisecond = 1000;
WebMClusterParser::WebMClusterParser(
int64_t timecode_scale,
scoped_refptr<AudioStreamInfo> audio_stream_info,
scoped_refptr<VideoStreamInfo> video_stream_info,
std::shared_ptr<AudioStreamInfo> audio_stream_info,
std::shared_ptr<VideoStreamInfo> video_stream_info,
int64_t audio_default_duration,
int64_t video_default_duration,
const WebMTracksParser::TextTracks& text_tracks,
@ -352,7 +352,7 @@ bool WebMClusterParser::OnBlock(bool is_simple_block,
int64_t timestamp = (cluster_timecode_ + timecode) * timecode_multiplier_;
scoped_refptr<MediaSample> buffer;
std::shared_ptr<MediaSample> buffer;
if (stream_type != kStreamText) {
// Every encrypted Block has a signal byte and IV prepended to it. Current
// encrypted WebM request for comments specification is here
@ -407,7 +407,7 @@ bool WebMClusterParser::OnBlock(bool is_simple_block,
: kNoTimestamp);
if (!init_cb_.is_null() && !initialized_) {
std::vector<scoped_refptr<StreamInfo>> streams;
std::vector<std::shared_ptr<StreamInfo>> streams;
if (audio_stream_info_)
streams.push_back(audio_stream_info_);
if (video_stream_info_) {
@ -474,7 +474,7 @@ WebMClusterParser::Track::Track(int track_num,
WebMClusterParser::Track::~Track() {}
bool WebMClusterParser::Track::EmitBuffer(
const scoped_refptr<MediaSample>& buffer) {
const std::shared_ptr<MediaSample>& buffer) {
DVLOG(2) << "EmitBuffer() : " << track_num_
<< " ts " << buffer->pts()
<< " dur " << buffer->duration()
@ -493,7 +493,7 @@ bool WebMClusterParser::Track::EmitBuffer(
<< last_added_buffer_missing_duration_->duration()
<< " kf " << last_added_buffer_missing_duration_->is_key_frame()
<< " size " << last_added_buffer_missing_duration_->data_size();
scoped_refptr<MediaSample> updated_buffer =
std::shared_ptr<MediaSample> updated_buffer =
last_added_buffer_missing_duration_;
last_added_buffer_missing_duration_ = NULL;
if (!EmitBufferHelp(updated_buffer))
@ -540,7 +540,7 @@ void WebMClusterParser::Track::Reset() {
}
bool WebMClusterParser::Track::EmitBufferHelp(
const scoped_refptr<MediaSample>& buffer) {
const std::shared_ptr<MediaSample>& buffer) {
DCHECK(!last_added_buffer_missing_duration_.get());
int64_t duration = buffer->duration();

View File

@ -50,7 +50,7 @@ class WebMClusterParser : public WebMParserClient {
// relative to |buffer|'s timestamp, and emits it and unsets
// |last_added_buffer_missing_duration_|. Otherwise, if |buffer| is missing
// duration, saves |buffer| into |last_added_buffer_missing_duration_|.
bool EmitBuffer(const scoped_refptr<MediaSample>& buffer);
bool EmitBuffer(const std::shared_ptr<MediaSample>& buffer);
// If |last_added_buffer_missing_duration_| is set, estimate the duration
// for this buffer using helper function GetDurationEstimate() then emits it
@ -67,7 +67,7 @@ class WebMClusterParser : public WebMParserClient {
// |estimated_next_frame_duration_|, and emits |buffer|.
// Returns false if |buffer| failed sanity check and therefore was not
// emitted. Returns true otherwise.
bool EmitBufferHelp(const scoped_refptr<MediaSample>& buffer);
bool EmitBufferHelp(const std::shared_ptr<MediaSample>& buffer);
// Helper function that calculates the buffer duration to use in
// ApplyDurationEstimateIfNeeded().
@ -79,7 +79,7 @@ class WebMClusterParser : public WebMParserClient {
// Holding the sample that is missing duration. The duration will be
// computed from the difference in timestamp when next sample arrives; or
// estimated if it is the last sample in this track.
scoped_refptr<MediaSample> last_added_buffer_missing_duration_;
std::shared_ptr<MediaSample> last_added_buffer_missing_duration_;
// If kNoTimestamp, then |estimated_next_frame_duration_| will be used.
int64_t default_duration_;
@ -118,8 +118,8 @@ class WebMClusterParser : public WebMParserClient {
/// @param decryption_key_source points to a decryption key source to fetch
/// decryption keys. Should not be NULL if the tracks are encrypted.
WebMClusterParser(int64_t timecode_scale,
scoped_refptr<AudioStreamInfo> audio_stream_info,
scoped_refptr<VideoStreamInfo> video_stream_info,
std::shared_ptr<AudioStreamInfo> audio_stream_info,
std::shared_ptr<VideoStreamInfo> video_stream_info,
int64_t audio_default_duration,
int64_t video_default_duration,
const WebMTracksParser::TextTracks& text_tracks,
@ -186,8 +186,8 @@ class WebMClusterParser : public WebMParserClient {
// Multiplier used to convert timecodes into microseconds.
double timecode_multiplier_;
scoped_refptr<AudioStreamInfo> audio_stream_info_;
scoped_refptr<VideoStreamInfo> video_stream_info_;
std::shared_ptr<AudioStreamInfo> audio_stream_info_;
std::shared_ptr<VideoStreamInfo> video_stream_info_;
std::set<int64_t> ignored_tracks_;
std::unique_ptr<DecryptorSource> decryptor_source_;

View File

@ -275,7 +275,7 @@ bool VerifyBuffersHelper(const BufferQueue& audio_buffers,
return false;
}
scoped_refptr<MediaSample> buffer = (*buffers)[(*offset)++];
std::shared_ptr<MediaSample> buffer = (*buffers)[(*offset)++];
EXPECT_EQ(block_info[i].timestamp * kMicrosecondsPerMillisecond,
buffer->pts());
@ -306,7 +306,7 @@ bool VerifyTextBuffers(const BlockInfo* block_info_ptr,
EXPECT_FALSE(block_info.use_simple_block);
EXPECT_FALSE(buffer_iter == buffer_end);
const scoped_refptr<MediaSample> buffer = *buffer_iter++;
const std::shared_ptr<MediaSample> buffer = *buffer_iter++;
EXPECT_EQ(block_info.timestamp * kMicrosecondsPerMillisecond,
buffer->pts());
EXPECT_EQ(std::abs(block_info.duration) * kMicrosecondsPerMillisecond,
@ -349,12 +349,12 @@ class WebMClusterParserTest : public testing::Test {
default_audio_duration, default_video_duration));
}
void InitEvent(const std::vector<scoped_refptr<StreamInfo>>& stream_info) {
void InitEvent(const std::vector<std::shared_ptr<StreamInfo>>& stream_info) {
streams_from_init_event_ = stream_info;
}
bool NewSampleEvent(uint32_t track_id,
const scoped_refptr<MediaSample>& sample) {
const std::shared_ptr<MediaSample>& sample) {
switch (track_id) {
case kAudioTrackNum:
audio_buffers_.push_back(sample);
@ -448,10 +448,10 @@ class WebMClusterParserTest : public testing::Test {
return result;
}
scoped_refptr<AudioStreamInfo> audio_stream_info_;
scoped_refptr<VideoStreamInfo> video_stream_info_;
std::shared_ptr<AudioStreamInfo> audio_stream_info_;
std::shared_ptr<VideoStreamInfo> video_stream_info_;
std::unique_ptr<WebMClusterParser> parser_;
std::vector<scoped_refptr<StreamInfo>> streams_from_init_event_;
std::vector<std::shared_ptr<StreamInfo>> streams_from_init_event_;
BufferQueue audio_buffers_;
BufferQueue video_buffers_;
TextBufferQueueMap text_buffers_map_;
@ -837,7 +837,7 @@ TEST_F(WebMClusterParserTest, ParseEncryptedBlock) {
EXPECT_EQ(cluster->size(), result);
EXPECT_TRUE(parser_->Flush());
ASSERT_EQ(1UL, video_buffers_.size());
scoped_refptr<MediaSample> buffer = video_buffers_[0];
std::shared_ptr<MediaSample> buffer = video_buffers_[0];
EXPECT_EQ(std::vector<uint8_t>(
kExpectedDecryptedFrame,
kExpectedDecryptedFrame + arraysize(kExpectedDecryptedFrame)),
@ -879,7 +879,7 @@ TEST_F(WebMClusterParserTest, ParseClearFrameInEncryptedTrack) {
EXPECT_EQ(cluster->size(), result);
EXPECT_TRUE(parser_->Flush());
ASSERT_EQ(1UL, video_buffers_.size());
scoped_refptr<MediaSample> buffer = video_buffers_[0];
std::shared_ptr<MediaSample> buffer = video_buffers_[0];
EXPECT_EQ(std::vector<uint8_t>(
kExpectedClearFrame,
kExpectedClearFrame + arraysize(kExpectedClearFrame)),

View File

@ -184,7 +184,7 @@ int WebMMediaParser::ParseInfoAndTracks(const uint8_t* data, int size) {
double timecode_scale_in_us = info_parser.timecode_scale() / 1000.0;
int64_t duration_in_us = info_parser.duration() * timecode_scale_in_us;
scoped_refptr<AudioStreamInfo> audio_stream_info =
std::shared_ptr<AudioStreamInfo> audio_stream_info =
tracks_parser.audio_stream_info();
if (audio_stream_info) {
audio_stream_info->set_duration(duration_in_us);
@ -192,7 +192,7 @@ int WebMMediaParser::ParseInfoAndTracks(const uint8_t* data, int size) {
VLOG(1) << "No audio track info found.";
}
scoped_refptr<VideoStreamInfo> video_stream_info =
std::shared_ptr<VideoStreamInfo> video_stream_info =
tracks_parser.video_stream_info();
if (video_stream_info) {
video_stream_info->set_duration(duration_in_us);

View File

@ -7,7 +7,6 @@
#include "packager/base/callback_forward.h"
#include "packager/base/compiler_specific.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/byte_queue.h"
#include "packager/media/base/media_parser.h"

View File

@ -74,7 +74,7 @@ Status WebMMuxer::Finalize() {
}
Status WebMMuxer::DoAddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) {
std::shared_ptr<MediaSample> sample) {
DCHECK(segmenter_);
DCHECK(stream == streams()[0]);
return segmenter_->AddSample(sample);

View File

@ -27,7 +27,7 @@ class WebMMuxer : public Muxer {
Status Initialize() override;
Status Finalize() override;
Status DoAddSample(const MediaStream* stream,
scoped_refptr<MediaSample> sample) override;
std::shared_ptr<MediaSample> sample) override;
void FireOnMediaStartEvent();
void FireOnMediaEndEvent();

View File

@ -51,7 +51,7 @@ class WebMTracksParser : public WebMParserClient {
return audio_encryption_key_id_;
}
scoped_refptr<AudioStreamInfo> audio_stream_info() {
std::shared_ptr<AudioStreamInfo> audio_stream_info() {
return audio_stream_info_;
}
@ -59,7 +59,7 @@ class WebMTracksParser : public WebMParserClient {
return video_encryption_key_id_;
}
scoped_refptr<VideoStreamInfo> video_stream_info() {
std::shared_ptr<VideoStreamInfo> video_stream_info() {
return video_stream_info_;
}
@ -100,10 +100,10 @@ class WebMTracksParser : public WebMParserClient {
std::string video_encryption_key_id_;
WebMAudioClient audio_client_;
scoped_refptr<AudioStreamInfo> audio_stream_info_;
std::shared_ptr<AudioStreamInfo> audio_stream_info_;
WebMVideoClient video_client_;
scoped_refptr<VideoStreamInfo> video_stream_info_;
std::shared_ptr<VideoStreamInfo> video_stream_info_;
DISALLOW_COPY_AND_ASSIGN(WebMTracksParser);
};

View File

@ -144,13 +144,13 @@ TEST_F(WebMTracksParserTest, AudioVideoDefaultDurationUnset) {
EXPECT_EQ(kNoTimestamp,
parser->GetVideoDefaultDuration(kDefaultTimecodeScaleInUs));
scoped_refptr<VideoStreamInfo> video_stream_info =
std::shared_ptr<VideoStreamInfo> video_stream_info =
parser->video_stream_info();
EXPECT_TRUE(video_stream_info);
EXPECT_EQ(320u, video_stream_info->width());
EXPECT_EQ(240u, video_stream_info->height());
scoped_refptr<AudioStreamInfo> audio_stream_info =
std::shared_ptr<AudioStreamInfo> audio_stream_info =
parser->audio_stream_info();
EXPECT_TRUE(audio_stream_info);
EXPECT_EQ(2u, audio_stream_info->num_channels());

View File

@ -47,7 +47,7 @@ void WebMVideoClient::Reset() {
alpha_mode_ = -1;
}
scoped_refptr<VideoStreamInfo> WebMVideoClient::GetVideoStreamInfo(
std::shared_ptr<VideoStreamInfo> WebMVideoClient::GetVideoStreamInfo(
int64_t track_num,
const std::string& codec_id,
const std::vector<uint8_t>& codec_private,
@ -64,11 +64,11 @@ scoped_refptr<VideoStreamInfo> WebMVideoClient::GetVideoStreamInfo(
video_codec = kCodecVP10;
} else {
LOG(ERROR) << "Unsupported video codec_id " << codec_id;
return scoped_refptr<VideoStreamInfo>();
return std::shared_ptr<VideoStreamInfo>();
}
if (pixel_width_ <= 0 || pixel_height_ <= 0)
return scoped_refptr<VideoStreamInfo>();
return std::shared_ptr<VideoStreamInfo>();
// Set crop and display unit defaults if these elements are not present.
if (crop_bottom_ == -1)
@ -96,10 +96,10 @@ scoped_refptr<VideoStreamInfo> WebMVideoClient::GetVideoStreamInfo(
display_height_ = height_after_crop;
} else if (display_unit_ == 3) {
if (display_width_ <= 0 || display_height_ <= 0)
return scoped_refptr<VideoStreamInfo>();
return std::shared_ptr<VideoStreamInfo>();
} else {
LOG(ERROR) << "Unsupported display unit type " << display_unit_;
return scoped_refptr<VideoStreamInfo>();
return std::shared_ptr<VideoStreamInfo>();
}
// Calculate sample aspect ratio.
int64_t sar_x = display_width_ * height_after_crop;
@ -108,10 +108,10 @@ scoped_refptr<VideoStreamInfo> WebMVideoClient::GetVideoStreamInfo(
sar_x /= gcd;
sar_y /= gcd;
return scoped_refptr<VideoStreamInfo>(new VideoStreamInfo(
return std::make_shared<VideoStreamInfo>(
track_num, kWebMTimeScale, 0, video_codec, std::string(),
codec_private.data(), codec_private.size(), width_after_crop,
height_after_crop, sar_x, sar_y, 0, 0, std::string(), is_encrypted));
height_after_crop, sar_x, sar_y, 0, 0, std::string(), is_encrypted);
}
bool WebMVideoClient::OnUInt(int id, int64_t val) {

View File

@ -28,10 +28,10 @@ class WebMVideoClient : public WebMParserClient {
/// Create a VideoStreamInfo with the data in |track_num|, |codec_id|,
/// |codec_private|, |is_encrypted| and the fields parsed from the last video
/// track element this object was used to parse.
/// @return A VideoStreamInfo scoped_refptr if successful.
/// @return An empty scoped_refptr if there was unexpected values in the
/// @return A VideoStreamInfo if successful.
/// @return An empty pointer if there was unexpected values in the
/// provided parameters or video track element fields.
scoped_refptr<VideoStreamInfo> GetVideoStreamInfo(
std::shared_ptr<VideoStreamInfo> GetVideoStreamInfo(
int64_t track_num,
const std::string& codec_id,
const std::vector<uint8_t>& codec_private,

View File

@ -188,7 +188,7 @@ bool ParseTimingAndSettingsLine(const std::string& line,
// comment --> side data (and side data only sample)
// settings --> side data
// start_time --> pts
scoped_refptr<MediaSample> CueToMediaSample(const Cue& cue) {
std::shared_ptr<MediaSample> CueToMediaSample(const Cue& cue) {
const bool kKeyFrame = true;
if (!cue.comment.empty()) {
const std::string comment = base::JoinString(cue.comment, "\n");
@ -197,12 +197,10 @@ scoped_refptr<MediaSample> CueToMediaSample(const Cue& cue) {
}
const std::string payload = base::JoinString(cue.payload, "\n");
scoped_refptr<MediaSample> media_sample = MediaSample::CopyFrom(
reinterpret_cast<const uint8_t*>(payload.data()),
payload.size(),
std::shared_ptr<MediaSample> media_sample = MediaSample::CopyFrom(
reinterpret_cast<const uint8_t*>(payload.data()), payload.size(),
reinterpret_cast<const uint8_t*>(cue.settings.data()),
cue.settings.size(),
!kKeyFrame);
cue.settings.size(), !kKeyFrame);
media_sample->set_config_id(cue.identifier);
media_sample->set_pts(cue.start_time);
@ -282,7 +280,7 @@ bool WebVttMediaParser::Parse(const uint8_t* buf, int size) {
break;
case kMetadata: {
if (line.empty()) {
std::vector<scoped_refptr<StreamInfo> > streams;
std::vector<std::shared_ptr<StreamInfo>> streams;
// The resolution of timings are in milliseconds.
const int kTimescale = 1000;
@ -294,8 +292,8 @@ bool WebVttMediaParser::Parse(const uint8_t* buf, int size) {
// There is no one metadata to determine what the language is. Parts
// of the text may be annotated as some specific language.
const char kLanguage[] = "";
streams.push_back(new TextStreamInfo(kTrackId, kTimescale, kDuration,
"wvtt",
streams.emplace_back(
new TextStreamInfo(kTrackId, kTimescale, kDuration, "wvtt",
base::JoinString(header_, "\n"),
0, // Not necessary.
0,

View File

@ -15,11 +15,12 @@
namespace shaka {
namespace media {
typedef testing::MockFunction<void(const std::vector<scoped_refptr<StreamInfo>>&
stream_info)> MockInitCallback;
typedef testing::MockFunction<bool(
uint32_t track_id,
const scoped_refptr<MediaSample>& media_sample)> MockNewSampleCallback;
typedef testing::MockFunction<void(
const std::vector<std::shared_ptr<StreamInfo>>& stream_info)>
MockInitCallback;
typedef testing::MockFunction<
bool(uint32_t track_id, const std::shared_ptr<MediaSample>& media_sample)>
MockNewSampleCallback;
using testing::_;
using testing::InSequence;

View File

@ -487,8 +487,9 @@ bool WvmMediaParser::Parse(const uint8_t* buf, int size) {
return true;
}
bool WvmMediaParser::EmitLastSample(uint32_t stream_id,
scoped_refptr<MediaSample>& new_sample) {
bool WvmMediaParser::EmitLastSample(
uint32_t stream_id,
const std::shared_ptr<MediaSample>& new_sample) {
std::string key = base::UintToString(current_program_id_)
.append(":")
.append(base::UintToString(stream_id));
@ -739,7 +740,7 @@ bool WvmMediaParser::ParseIndexEntry() {
if (has_video) {
Codec video_codec = kCodecH264;
stream_infos_.push_back(new VideoStreamInfo(
stream_infos_.emplace_back(new VideoStreamInfo(
stream_id_count_, time_scale, track_duration, video_codec,
std::string(), video_codec_config.data(), video_codec_config.size(),
video_width, video_height, pixel_width, pixel_height, trick_play_rate,
@ -754,7 +755,7 @@ bool WvmMediaParser::ParseIndexEntry() {
if (has_audio) {
const Codec audio_codec = kCodecAAC;
// TODO(beil): Pass in max and average bitrate in wvm container.
stream_infos_.push_back(new AudioStreamInfo(
stream_infos_.emplace_back(new AudioStreamInfo(
stream_id_count_, time_scale, track_duration, audio_codec,
std::string(), audio_codec_config.data(), audio_codec_config.size(),
kAacSampleSizeBits, num_channels, sampling_frequency,
@ -994,7 +995,7 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) {
bool WvmMediaParser::EmitSample(uint32_t parsed_audio_or_video_stream_id,
uint32_t stream_id,
scoped_refptr<MediaSample>& new_sample,
const std::shared_ptr<MediaSample>& new_sample,
bool isLastSample) {
DCHECK(new_sample);
if (isLastSample) {

View File

@ -32,7 +32,7 @@ struct DemuxStreamIdMediaSample {
~DemuxStreamIdMediaSample();
uint32_t demux_stream_id;
uint32_t parsed_audio_or_video_stream_id;
scoped_refptr<MediaSample> media_sample;
std::shared_ptr<MediaSample> media_sample;
};
struct PrevSampleData {
@ -40,8 +40,8 @@ struct PrevSampleData {
PrevSampleData();
~PrevSampleData();
void Reset();
scoped_refptr<MediaSample> audio_sample;
scoped_refptr<MediaSample> video_sample;
std::shared_ptr<MediaSample> audio_sample;
std::shared_ptr<MediaSample> video_sample;
uint32_t audio_stream_id;
uint32_t video_stream_id;
int64_t audio_sample_duration;
@ -206,13 +206,13 @@ class WvmMediaParser : public MediaParser {
// to emit a new audio/video access unit.
bool EmitSample(uint32_t parsed_audio_or_video_stream_id,
uint32_t stream_id,
scoped_refptr<MediaSample>& new_sample,
const std::shared_ptr<MediaSample>& new_sample,
bool isLastSample);
bool EmitPendingSamples();
bool EmitLastSample(uint32_t stream_id,
scoped_refptr<MediaSample>& new_sample);
const std::shared_ptr<MediaSample>& new_sample);
// List of callbacks.t
InitCB init_cb_;
@ -237,7 +237,7 @@ class WvmMediaParser : public MediaParser {
uint64_t pts_;
uint64_t dts_;
uint8_t index_program_id_;
scoped_refptr<MediaSample> media_sample_;
std::shared_ptr<MediaSample> media_sample_;
size_t crypto_unit_start_pos_;
PrevSampleData prev_media_sample_data_;
H264ByteToUnitStreamConverter byte_to_unit_stream_converter_;
@ -247,7 +247,7 @@ class WvmMediaParser : public MediaParser {
std::vector<uint8_t> index_data_;
std::map<std::string, uint32_t> program_demux_stream_map_;
int stream_id_count_;
std::vector<scoped_refptr<StreamInfo> > stream_infos_;
std::vector<std::shared_ptr<StreamInfo>> stream_infos_;
std::deque<DemuxStreamIdMediaSample> media_sample_queue_;
std::vector<uint8_t> sample_data_;
KeySource* decryption_key_source_;

View File

@ -11,7 +11,6 @@
#include "packager/base/bind.h"
#include "packager/base/bind_helpers.h"
#include "packager/base/logging.h"
#include "packager/base/memory/ref_counted.h"
#include "packager/media/base/audio_stream_info.h"
#include "packager/media/base/fixed_key_source.h"
#include "packager/media/base/media_sample.h"
@ -78,7 +77,7 @@ class WvmMediaParserTest : public testing::Test {
}
protected:
typedef std::map<int, scoped_refptr<StreamInfo> > StreamMap;
typedef std::map<int, std::shared_ptr<StreamInfo>> StreamMap;
std::unique_ptr<WvmMediaParser> parser_;
std::unique_ptr<MockKeySource> key_source_;
@ -90,17 +89,16 @@ class WvmMediaParserTest : public testing::Test {
int32_t current_track_id_;
EncryptionKey encryption_key_;
void OnInit(const std::vector<scoped_refptr<StreamInfo> >& stream_infos) {
void OnInit(const std::vector<std::shared_ptr<StreamInfo>>& stream_infos) {
DVLOG(1) << "OnInit: " << stream_infos.size() << " streams.";
for (std::vector<scoped_refptr<StreamInfo> >::const_iterator iter =
stream_infos.begin(); iter != stream_infos.end(); ++iter) {
DVLOG(1) << (*iter)->ToString();
stream_map_[(*iter)->track_id()] = *iter;
for (const auto& stream_info : stream_infos) {
DVLOG(1) << stream_info->ToString();
stream_map_[stream_info->track_id()] = stream_info;
}
}
bool OnNewSample(uint32_t track_id,
const scoped_refptr<MediaSample>& sample) {
const std::shared_ptr<MediaSample>& sample) {
std::string stream_type;
if (static_cast<int32_t>(track_id) != current_track_id_) {
// onto next track.