diff --git a/packager/media/base/demuxer.cc b/packager/media/base/demuxer.cc index 95f4ef5708..ad6f2c98e3 100644 --- a/packager/media/base/demuxer.cc +++ b/packager/media/base/demuxer.cc @@ -30,22 +30,22 @@ const size_t kBufSize = 0x200000; // 2MB // samples before seeing init_event, something is not right. The number // set here is arbitrary though. const size_t kQueuedSamplesLimit = 10000; -const int kInvalidStreamIndex = -1; -const int kBaseVideoOutputStreamIndex = 0x100; -const int kBaseAudioOutputStreamIndex = 0x200; +const size_t kInvalidStreamIndex = static_cast(-1); +const size_t kBaseVideoOutputStreamIndex = 0x100; +const size_t kBaseAudioOutputStreamIndex = 0x200; -std::string GetStreamLabel(int stream_index) { +std::string GetStreamLabel(size_t stream_index) { switch (stream_index) { case kBaseVideoOutputStreamIndex: return "video"; case kBaseAudioOutputStreamIndex: return "audio"; default: - return base::IntToString(stream_index); + return base::SizeTToString(stream_index); } } -bool GetStreamIndex(const std::string& stream_label, int* stream_index) { +bool GetStreamIndex(const std::string& stream_label, size_t* stream_index) { DCHECK(stream_index); if (stream_label == "video") { *stream_index = kBaseVideoOutputStreamIndex; @@ -53,7 +53,7 @@ bool GetStreamIndex(const std::string& stream_label, int* stream_index) { *stream_index = kBaseAudioOutputStreamIndex; } else { // Expect stream_label to be a zero based stream id. - if (!base::StringToInt(stream_label, stream_index)) { + if (!base::StringToSizeT(stream_label, stream_index)) { LOG(ERROR) << "Invalid argument --stream=" << stream_label << "; " << "should be 'audio', 'video', or a number"; return false; @@ -106,7 +106,7 @@ Status Demuxer::Run() { return Status(error::CANCELLED, "Demuxer run cancelled"); if (status.error_code() == error::END_OF_STREAM) { - for (int stream_index : stream_indexes_) { + for (size_t stream_index : stream_indexes_) { status = FlushDownstream(stream_index); if (!status.ok()) return status; @@ -122,7 +122,7 @@ void Demuxer::Cancel() { Status Demuxer::SetHandler(const std::string& stream_label, std::shared_ptr handler) { - int stream_index = kInvalidStreamIndex; + size_t stream_index = kInvalidStreamIndex; if (!GetStreamIndex(stream_label, &stream_index)) { return Status(error::INVALID_ARGUMENT, "Invalid stream: " + stream_label); @@ -132,7 +132,7 @@ Status Demuxer::SetHandler(const std::string& stream_label, void Demuxer::SetLanguageOverride(const std::string& stream_label, const std::string& language_override) { - int stream_index = kInvalidStreamIndex; + size_t stream_index = kInvalidStreamIndex; if (!GetStreamIndex(stream_label, &stream_index)) LOG(WARNING) << "Invalid stream for language override " << stream_label; language_overrides_[stream_index] = language_override; @@ -222,7 +222,7 @@ void Demuxer::ParserInitEvent( output_handlers().find(kBaseAudioOutputStreamIndex) != output_handlers().end(); for (const std::shared_ptr& stream_info : stream_infos) { - int stream_index = base_stream_index; + size_t stream_index = base_stream_index; if (video_handler_set && stream_info->stream_type() == kStreamVideo) { stream_index = kBaseVideoOutputStreamIndex; // Only for the first video stream. diff --git a/packager/media/base/demuxer.h b/packager/media/base/demuxer.h index d2527e0fea..1216d2971f 100644 --- a/packager/media/base/demuxer.h +++ b/packager/media/base/demuxer.h @@ -82,7 +82,7 @@ class Demuxer : public MediaHandler { return Status(error::INTERNAL_ERROR, "Demuxer should not be the downstream handler."); } - bool ValidateOutputStreamIndex(int stream_index) const override { + bool ValidateOutputStreamIndex(size_t stream_index) const override { // We don't know if the stream is valid or not when setting up the graph. // Will validate the stream index later when stream info is available. return true; @@ -128,12 +128,12 @@ class Demuxer : public MediaHandler { std::deque queued_samples_; std::unique_ptr parser_; // TrackId -> StreamIndex map. - std::map track_id_to_stream_index_map_; + std::map track_id_to_stream_index_map_; // The list of stream indexes in the above map (in the same order as the input // stream info vector). - std::vector stream_indexes_; + std::vector stream_indexes_; // StreamIndex -> language_override map. - std::map language_overrides_; + std::map language_overrides_; MediaContainerName container_name_ = CONTAINER_UNKNOWN; std::unique_ptr buffer_; std::unique_ptr key_source_; diff --git a/packager/media/base/media_handler.cc b/packager/media/base/media_handler.cc index 84758de4d3..a806761df5 100644 --- a/packager/media/base/media_handler.cc +++ b/packager/media/base/media_handler.cc @@ -9,10 +9,8 @@ namespace shaka { namespace media { -Status MediaHandler::SetHandler(int output_stream_index, +Status MediaHandler::SetHandler(size_t output_stream_index, std::shared_ptr handler) { - if (output_stream_index < 0) - return Status(error::INVALID_ARGUMENT, "Invalid output stream index"); if (output_handlers_.find(output_stream_index) != output_handlers_.end()) { return Status(error::ALREADY_EXISTS, "The handler at the specified index already exists."); @@ -40,19 +38,19 @@ Status MediaHandler::Initialize() { return Status::OK; } -Status MediaHandler::OnFlushRequest(int input_stream_index) { +Status MediaHandler::OnFlushRequest(size_t input_stream_index) { // The default implementation treats the output stream index to be identical // to the input stream index, which is true for most handlers. - const int output_stream_index = input_stream_index; + const size_t output_stream_index = input_stream_index; return FlushDownstream(output_stream_index); } -bool MediaHandler::ValidateOutputStreamIndex(int stream_index) const { - return stream_index >= 0 && stream_index < num_input_streams_; +bool MediaHandler::ValidateOutputStreamIndex(size_t stream_index) const { + return stream_index < num_input_streams_; } Status MediaHandler::Dispatch(std::unique_ptr stream_data) { - int output_stream_index = stream_data->stream_index; + size_t output_stream_index = stream_data->stream_index; auto handler_it = output_handlers_.find(output_stream_index); if (handler_it == output_handlers_.end()) { return Status(error::NOT_FOUND, @@ -62,7 +60,7 @@ Status MediaHandler::Dispatch(std::unique_ptr stream_data) { return handler_it->second.first->Process(std::move(stream_data)); } -Status MediaHandler::FlushDownstream(int output_stream_index) { +Status MediaHandler::FlushDownstream(size_t output_stream_index) { auto handler_it = output_handlers_.find(output_stream_index); if (handler_it == output_handlers_.end()) { return Status(error::NOT_FOUND, diff --git a/packager/media/base/media_handler.h b/packager/media/base/media_handler.h index 6053d255f8..6ee664b845 100644 --- a/packager/media/base/media_handler.h +++ b/packager/media/base/media_handler.h @@ -41,7 +41,7 @@ struct SegmentInfo { // TODO(kqyang): Should we use protobuf? struct StreamData { - int stream_index = -1; + size_t stream_index = -1; StreamDataType stream_data_type = StreamDataType::kUnknown; std::shared_ptr period_info; @@ -73,7 +73,7 @@ class MediaHandler { virtual ~MediaHandler() = default; /// Connect downstream handler at the specified output stream index. - Status SetHandler(int output_stream_index, + Status SetHandler(size_t output_stream_index, std::shared_ptr handler); /// Connect downstream handler to the next availble output stream index. @@ -97,20 +97,20 @@ class MediaHandler { virtual Status Process(std::unique_ptr stream_data) = 0; /// Event handler for flush request at the specific input stream index. - virtual Status OnFlushRequest(int input_stream_index); + virtual Status OnFlushRequest(size_t input_stream_index); /// Validate if the stream at the specified index actually exists. - virtual bool ValidateOutputStreamIndex(int stream_index) const; + virtual bool ValidateOutputStreamIndex(size_t stream_index) const; bool initialized() { return initialized_; } - int num_input_streams() { return num_input_streams_; } + size_t num_input_streams() { return num_input_streams_; } /// Dispatch the stream data to downstream handlers. Note that /// stream_data.stream_index should be the output stream index. Status Dispatch(std::unique_ptr stream_data); /// Dispatch the period info to downstream handlers. - Status DispatchPeriodInfo(int stream_index, + Status DispatchPeriodInfo(size_t stream_index, std::shared_ptr period_info) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; @@ -120,7 +120,7 @@ class MediaHandler { } /// Dispatch the stream info to downstream handlers. - Status DispatchStreamInfo(int stream_index, + Status DispatchStreamInfo(size_t stream_index, std::shared_ptr stream_info) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; @@ -131,7 +131,7 @@ class MediaHandler { /// Dispatch the encryption config to downstream handlers. Status DispatchEncryptionConfig( - int stream_index, + size_t stream_index, std::unique_ptr encryption_config) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; @@ -141,7 +141,7 @@ class MediaHandler { } /// Dispatch the media sample to downstream handlers. - Status DispatchMediaSample(int stream_index, + Status DispatchMediaSample(size_t stream_index, std::shared_ptr media_sample) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; @@ -151,7 +151,7 @@ class MediaHandler { } /// Dispatch the media event to downstream handlers. - Status DispatchMediaEvent(int stream_index, + Status DispatchMediaEvent(size_t stream_index, std::shared_ptr media_event) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; @@ -161,7 +161,7 @@ class MediaHandler { } /// Dispatch the segment info to downstream handlers. - Status DispatchSegmentInfo(int stream_index, + Status DispatchSegmentInfo(size_t stream_index, std::shared_ptr segment_info) { std::unique_ptr stream_data(new StreamData); stream_data->stream_index = stream_index; @@ -171,11 +171,11 @@ class MediaHandler { } /// Flush the downstream connected at the specified output stream index. - Status FlushDownstream(int output_stream_index); + Status FlushDownstream(size_t output_stream_index); - int num_input_streams() const { return num_input_streams_; } - int next_output_stream_index() const { return next_output_stream_index_; } - const std::map, int>>& + size_t num_input_streams() const { return num_input_streams_; } + size_t next_output_stream_index() const { return next_output_stream_index_; } + const std::map, size_t>>& output_handlers() { return output_handlers_; } @@ -186,12 +186,13 @@ class MediaHandler { bool initialized_ = false; // Number of input streams. - int num_input_streams_ = 0; + size_t num_input_streams_ = 0; // The next available output stream index, used by AddHandler. - int next_output_stream_index_ = 0; + size_t next_output_stream_index_ = 0; // output stream index -> {output handler, output handler input stream index} // map. - std::map, int>> output_handlers_; + std::map, size_t>> + output_handlers_; }; } // namespace media diff --git a/packager/media/base/media_handler_test_base.cc b/packager/media/base/media_handler_test_base.cc index 79cf1092ce..c730c58546 100644 --- a/packager/media/base/media_handler_test_base.cc +++ b/packager/media/base/media_handler_test_base.cc @@ -73,8 +73,8 @@ class FakeMediaHandler : public MediaHandler { stream_data_vector_.push_back(std::move(stream_data)); return Status::OK; } - Status OnFlushRequest(int input_stream_index) override { return Status::OK; } - bool ValidateOutputStreamIndex(int stream_index) const override { + Status OnFlushRequest(size_t input_stream_index) override { return Status::OK; } + bool ValidateOutputStreamIndex(size_t stream_index) const override { return true; } diff --git a/packager/media/base/muxer.h b/packager/media/base/muxer.h index 2c62cc08e4..347a52fd3c 100644 --- a/packager/media/base/muxer.h +++ b/packager/media/base/muxer.h @@ -97,7 +97,7 @@ class Muxer : public MediaHandler { /// @{ Status InitializeInternal() override { return Status::OK; } Status Process(std::unique_ptr stream_data) override; - Status OnFlushRequest(int input_stream_index) override { return Finalize(); } + Status OnFlushRequest(size_t input_stream_index) override { return Finalize(); } /// @} const MuxerOptions& options() const { return options_; } @@ -124,11 +124,11 @@ class Muxer : public MediaHandler { virtual Status Finalize() = 0; // Add a new sample. - virtual Status AddSample(int stream_id, + virtual Status AddSample(size_t stream_id, std::shared_ptr sample) = 0; // Finalize the segment or subsegment. - virtual Status FinalizeSegment(int stream_id, + virtual Status FinalizeSegment(size_t stream_id, std::shared_ptr segment_info) = 0; MuxerOptions options_; diff --git a/packager/media/chunking/chunking_handler.cc b/packager/media/chunking/chunking_handler.cc index 562edf164b..aafb184b90 100644 --- a/packager/media/chunking/chunking_handler.cc +++ b/packager/media/chunking/chunking_handler.cc @@ -50,7 +50,7 @@ Status ChunkingHandler::Process(std::unique_ptr stream_data) { // The video stream is treated as the main stream. If there is only one // stream, it is the main stream. const bool is_main_stream = - main_stream_index_ == -1 && + main_stream_index_ == kInvalidStreamIndex && (stream_data->stream_info->stream_type() == kStreamVideo || num_input_streams() == 1); if (is_main_stream) { @@ -70,7 +70,7 @@ Status ChunkingHandler::Process(std::unique_ptr stream_data) { VLOG(3) << "Drop existing segment info."; return Status::OK; case StreamDataType::kMediaSample: { - const int stream_index = stream_data->stream_index; + const size_t stream_index = stream_data->stream_index; DCHECK_NE(time_scales_[stream_index], 0u) << "kStreamInfo should arrive before kMediaSample"; if (stream_index != main_stream_index_) { @@ -111,7 +111,7 @@ Status ChunkingHandler::Process(std::unique_ptr stream_data) { return Dispatch(std::move(stream_data)); } -Status ChunkingHandler::OnFlushRequest(int input_stream_index) { +Status ChunkingHandler::OnFlushRequest(size_t input_stream_index) { if (segment_info_[input_stream_index]) { Status status; if (input_stream_index != main_stream_index_) { @@ -185,7 +185,7 @@ Status ChunkingHandler::DispatchNonMainSamples(int64_t timestamp_threshold) { while (status.ok() && !non_main_samples_.empty()) { DCHECK_EQ(non_main_samples_.front()->stream_data_type, StreamDataType::kMediaSample); - const int stream_index = non_main_samples_.front()->stream_index; + const size_t stream_index = non_main_samples_.front()->stream_index; const MediaSample* sample = non_main_samples_.front()->media_sample.get(); // If the portion of the sample before |timestamp_threshold| is bigger than // the other portion, we consider it part of the current segment. @@ -225,8 +225,7 @@ Status ChunkingHandler::DispatchNonMainSamples(int64_t timestamp_threshold) { Status ChunkingHandler::DispatchSegmentInfoForAllStreams() { Status status; - for (int i = 0; i < static_cast(segment_info_.size()) && status.ok(); - ++i) { + for (size_t i = 0; i < segment_info_.size() && status.ok(); ++i) { if (segment_info_[i] && segment_info_[i]->start_timestamp != -1) { segment_info_[i]->duration = last_sample_end_timestamps_[i] - segment_info_[i]->start_timestamp; @@ -240,8 +239,7 @@ Status ChunkingHandler::DispatchSegmentInfoForAllStreams() { Status ChunkingHandler::DispatchSubsegmentInfoForAllStreams() { Status status; - for (int i = 0; i < static_cast(subsegment_info_.size()) && status.ok(); - ++i) { + for (size_t i = 0; i < subsegment_info_.size() && status.ok(); ++i) { if (subsegment_info_[i] && subsegment_info_[i]->start_timestamp != -1) { subsegment_info_[i]->duration = last_sample_end_timestamps_[i] - subsegment_info_[i]->start_timestamp; diff --git a/packager/media/chunking/chunking_handler.h b/packager/media/chunking/chunking_handler.h index 67841efbfd..e392ac0361 100644 --- a/packager/media/chunking/chunking_handler.h +++ b/packager/media/chunking/chunking_handler.h @@ -68,7 +68,7 @@ class ChunkingHandler : public MediaHandler { /// @{ Status InitializeInternal() override; Status Process(std::unique_ptr stream_data) override; - Status OnFlushRequest(int input_stream_index) override; + Status OnFlushRequest(size_t input_stream_index) override; /// @} private: @@ -94,7 +94,8 @@ class ChunkingHandler : public MediaHandler { // The video stream is the main stream; if there is only one stream, it is the // main stream. The chunking is based on the main stream. - int main_stream_index_ = -1; + const size_t kInvalidStreamIndex = static_cast(-1); + size_t main_stream_index_ = kInvalidStreamIndex; // Segment and subsegment duration in main stream's time scale. int64_t segment_duration_ = 0; int64_t subsegment_duration_ = 0; diff --git a/packager/media/chunking/chunking_handler_unittest.cc b/packager/media/chunking/chunking_handler_unittest.cc index 5e1072311f..2f015b7bb7 100644 --- a/packager/media/chunking/chunking_handler_unittest.cc +++ b/packager/media/chunking/chunking_handler_unittest.cc @@ -18,8 +18,8 @@ using ::testing::IsEmpty; namespace shaka { namespace media { namespace { -const int kStreamIndex0 = 0; -const int kStreamIndex1 = 1; +const size_t kStreamIndex0 = 0; +const size_t kStreamIndex1 = 1; const uint32_t kTimeScale0 = 800; const uint32_t kTimeScale1 = 1000; const int64_t kDuration0 = 200; diff --git a/packager/media/crypto/encryption_handler_unittest.cc b/packager/media/crypto/encryption_handler_unittest.cc index bbb27fce84..628d5a8da6 100644 --- a/packager/media/crypto/encryption_handler_unittest.cc +++ b/packager/media/crypto/encryption_handler_unittest.cc @@ -104,7 +104,7 @@ TEST_F(EncryptionHandlerTest, OnlyOneInput) { namespace { -const int kStreamIndex = 0; +const size_t kStreamIndex = 0; const bool kEncrypted = true; const uint32_t kTimeScale = 1000; const uint32_t kMaxSdPixels = 100u; @@ -335,7 +335,7 @@ TEST_P(EncryptionHandlerEncryptionTest, Encrypt) { DoAll(SetArgPointee<1>(GetMockEncryptionKey()), Return(Status::OK))); ASSERT_OK(Process(std::move(stream_data))); ASSERT_EQ(2u, GetOutputStreamDataVector().size()); - ASSERT_EQ(0, GetOutputStreamDataVector().back()->stream_index); + ASSERT_EQ(0u, GetOutputStreamDataVector().back()->stream_index); ASSERT_EQ(StreamDataType::kMediaSample, GetOutputStreamDataVector().back()->stream_data_type); diff --git a/packager/media/formats/mp2t/ts_muxer.cc b/packager/media/formats/mp2t/ts_muxer.cc index 611fbf4409..616448150a 100644 --- a/packager/media/formats/mp2t/ts_muxer.cc +++ b/packager/media/formats/mp2t/ts_muxer.cc @@ -34,14 +34,15 @@ Status TsMuxer::Finalize() { return segmenter_->Finalize(); } -Status TsMuxer::AddSample(int stream_id, std::shared_ptr sample) { - DCHECK_EQ(stream_id, 0); +Status TsMuxer::AddSample(size_t stream_id, + std::shared_ptr sample) { + DCHECK_EQ(stream_id, 0u); return segmenter_->AddSample(sample); } -Status TsMuxer::FinalizeSegment(int stream_id, +Status TsMuxer::FinalizeSegment(size_t stream_id, std::shared_ptr segment_info) { - DCHECK_EQ(stream_id, 0); + DCHECK_EQ(stream_id, 0u); return segment_info->is_subsegment ? Status::OK : segmenter_->FinalizeSegment(segment_info->start_timestamp, diff --git a/packager/media/formats/mp2t/ts_muxer.h b/packager/media/formats/mp2t/ts_muxer.h index 9271fd7910..51001637fa 100644 --- a/packager/media/formats/mp2t/ts_muxer.h +++ b/packager/media/formats/mp2t/ts_muxer.h @@ -26,8 +26,9 @@ class TsMuxer : public Muxer { // Muxer implementation. Status InitializeMuxer() override; Status Finalize() override; - Status AddSample(int stream_id, std::shared_ptr sample) override; - Status FinalizeSegment(int stream_id, + Status AddSample(size_t stream_id, + std::shared_ptr sample) override; + Status FinalizeSegment(size_t stream_id, std::shared_ptr sample) override; void FireOnMediaStartEvent(); diff --git a/packager/media/formats/mp4/mp4_muxer.cc b/packager/media/formats/mp4/mp4_muxer.cc index 9e1b6add7a..1b1b6c5961 100644 --- a/packager/media/formats/mp4/mp4_muxer.cc +++ b/packager/media/formats/mp4/mp4_muxer.cc @@ -161,12 +161,13 @@ Status MP4Muxer::Finalize() { return Status::OK; } -Status MP4Muxer::AddSample(int stream_id, std::shared_ptr sample) { +Status MP4Muxer::AddSample(size_t stream_id, + std::shared_ptr sample) { DCHECK(segmenter_); return segmenter_->AddSample(stream_id, sample); } -Status MP4Muxer::FinalizeSegment(int stream_id, +Status MP4Muxer::FinalizeSegment(size_t stream_id, std::shared_ptr segment_info) { DCHECK(segmenter_); VLOG(3) << "Finalize " << (segment_info->is_subsegment ? "sub" : "") diff --git a/packager/media/formats/mp4/mp4_muxer.h b/packager/media/formats/mp4/mp4_muxer.h index 8832ce7182..5f60ea611c 100644 --- a/packager/media/formats/mp4/mp4_muxer.h +++ b/packager/media/formats/mp4/mp4_muxer.h @@ -37,8 +37,9 @@ class MP4Muxer : public Muxer { // Muxer implementation overrides. Status InitializeMuxer() override; Status Finalize() override; - Status AddSample(int stream_id, std::shared_ptr sample) override; - Status FinalizeSegment(int stream_id, + Status AddSample(size_t stream_id, + std::shared_ptr sample) override; + Status FinalizeSegment(size_t stream_id, std::shared_ptr segment_info) override; // Generate Audio/Video Track box. diff --git a/packager/media/formats/mp4/segmenter.cc b/packager/media/formats/mp4/segmenter.cc index 954672a378..d7b8894ba2 100644 --- a/packager/media/formats/mp4/segmenter.cc +++ b/packager/media/formats/mp4/segmenter.cc @@ -308,7 +308,7 @@ Status Segmenter::Finalize() { return DoFinalize(); } -Status Segmenter::AddSample(int stream_id, +Status Segmenter::AddSample(size_t stream_id, std::shared_ptr sample) { // Set default sample duration if it has not been set yet. if (moov_->extends.tracks[stream_id].default_sample_duration == 0) { @@ -316,7 +316,7 @@ Status Segmenter::AddSample(int stream_id, sample->duration(); } - DCHECK_LT(stream_id, static_cast(fragmenters_.size())); + DCHECK_LT(stream_id, fragmenters_.size()); Fragmenter* fragmenter = fragmenters_[stream_id].get(); if (fragmenter->fragment_finalized()) { return Status(error::FRAGMENT_FINALIZED, @@ -333,8 +333,8 @@ Status Segmenter::AddSample(int stream_id, return Status::OK; } -Status Segmenter::FinalizeSegment(int stream_id, bool is_subsegment) { - DCHECK_LT(stream_id, static_cast(fragmenters_.size())); +Status Segmenter::FinalizeSegment(size_t stream_id, bool is_subsegment) { + DCHECK_LT(stream_id, fragmenters_.size()); Fragmenter* fragmenter = fragmenters_[stream_id].get(); DCHECK(fragmenter); fragmenter->FinalizeFragment(); diff --git a/packager/media/formats/mp4/segmenter.h b/packager/media/formats/mp4/segmenter.h index 477ea0f9a3..cf416485af 100644 --- a/packager/media/formats/mp4/segmenter.h +++ b/packager/media/formats/mp4/segmenter.h @@ -88,13 +88,13 @@ class Segmenter { /// @param stream_id is the zero-based stream index. /// @param sample points to the sample to be added. /// @return OK on success, an error status otherwise. - Status AddSample(int stream_id, std::shared_ptr sample); + Status AddSample(size_t stream_id, std::shared_ptr sample); /// Finalize the segment / subsegment. /// @param stream_id is the zero-based stream index. /// @param is_subsegment indicates if it is a subsegment (fragment). /// @return OK on success, an error status otherwise. - Status FinalizeSegment(int stream_id, bool is_subsegment); + Status FinalizeSegment(size_t stream_id, bool is_subsegment); /// @return true if there is an initialization range, while setting @a offset /// and @a size; or false if initialization range does not apply. diff --git a/packager/media/formats/webm/webm_muxer.cc b/packager/media/formats/webm/webm_muxer.cc index c96d75004f..08c402d310 100644 --- a/packager/media/formats/webm/webm_muxer.cc +++ b/packager/media/formats/webm/webm_muxer.cc @@ -72,17 +72,17 @@ Status WebMMuxer::Finalize() { return Status::OK; } -Status WebMMuxer::AddSample(int stream_id, +Status WebMMuxer::AddSample(size_t stream_id, std::shared_ptr sample) { DCHECK(segmenter_); - DCHECK_EQ(stream_id, 0); + DCHECK_EQ(stream_id, 0u); return segmenter_->AddSample(sample); } -Status WebMMuxer::FinalizeSegment(int stream_id, +Status WebMMuxer::FinalizeSegment(size_t stream_id, std::shared_ptr segment_info) { DCHECK(segmenter_); - DCHECK_EQ(stream_id, 0); + DCHECK_EQ(stream_id, 0u); return segmenter_->FinalizeSegment(segment_info->start_timestamp, segment_info->duration, segment_info->is_subsegment); diff --git a/packager/media/formats/webm/webm_muxer.h b/packager/media/formats/webm/webm_muxer.h index 6aba30b565..e9d016dcd9 100644 --- a/packager/media/formats/webm/webm_muxer.h +++ b/packager/media/formats/webm/webm_muxer.h @@ -26,8 +26,9 @@ class WebMMuxer : public Muxer { // Muxer implementation overrides. Status InitializeMuxer() override; Status Finalize() override; - Status AddSample(int stream_id, std::shared_ptr sample) override; - Status FinalizeSegment(int stream_id, + Status AddSample(size_t stream_id, + std::shared_ptr sample) override; + Status FinalizeSegment(size_t stream_id, std::shared_ptr segment_info) override; void FireOnMediaStartEvent();