diff --git a/packager/app/muxer_factory.h b/packager/app/muxer_factory.h index ca7a799aaa..8ea5d27fe9 100644 --- a/packager/app/muxer_factory.h +++ b/packager/app/muxer_factory.h @@ -42,7 +42,7 @@ class MuxerFactory { /// this will replace the clock for all muxers created after this call. void OverrideClock(base::Clock* clock); - void SetTsStreamOffset(uint32_t offset_ms) { + void SetTsStreamOffset(int32_t offset_ms) { transport_stream_timestamp_offset_ms_ = offset_ms; } @@ -52,7 +52,7 @@ class MuxerFactory { const Mp4OutputParams mp4_params_; const std::string temp_dir_; - uint32_t transport_stream_timestamp_offset_ms_ = 0; + int32_t transport_stream_timestamp_offset_ms_ = 0; base::Clock* clock_ = nullptr; }; diff --git a/packager/file/http_file.cc b/packager/file/http_file.cc index 5db5a44adb..b304746f99 100644 --- a/packager/file/http_file.cc +++ b/packager/file/http_file.cc @@ -157,7 +157,7 @@ HttpFile::HttpFile(HttpMethod method, const std::string& url, const std::string& upload_content_type, const std::vector& headers, - uint32_t timeout_in_seconds) + int32_t timeout_in_seconds) : File(url.c_str()), url_(url), upload_content_type_(upload_content_type), diff --git a/packager/file/http_file.h b/packager/file/http_file.h index 92f30b4d19..7351e0851d 100644 --- a/packager/file/http_file.h +++ b/packager/file/http_file.h @@ -42,7 +42,7 @@ class HttpFile : public File { const std::string& url, const std::string& upload_content_type, const std::vector& headers, - uint32_t timeout_in_seconds); + int32_t timeout_in_seconds); HttpFile(const HttpFile&) = delete; HttpFile& operator=(const HttpFile&) = delete; @@ -75,7 +75,7 @@ class HttpFile : public File { const std::string url_; const std::string upload_content_type_; - const uint32_t timeout_in_seconds_; + const int32_t timeout_in_seconds_; const HttpMethod method_; IoCache download_cache_; IoCache upload_cache_; diff --git a/packager/hls/base/hls_notifier.h b/packager/hls/base/hls_notifier.h index 8e2c81875f..3b1504fa76 100644 --- a/packager/hls/base/hls_notifier.h +++ b/packager/hls/base/hls_notifier.h @@ -48,7 +48,7 @@ class HlsNotifier { /// @return true on success, false otherwise. This may fail if the stream /// specified by @a stream_id does not exist. virtual bool NotifySampleDuration(uint32_t stream_id, - uint32_t sample_duration) = 0; + int32_t sample_duration) = 0; /// @param stream_id is the value set by NotifyNewStream(). /// @param segment_name is the name of the new segment. @@ -60,8 +60,8 @@ class HlsNotifier { /// @param size is the size in bytes. virtual bool NotifyNewSegment(uint32_t stream_id, const std::string& segment_name, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t start_byte_offset, uint64_t size) = 0; @@ -72,14 +72,14 @@ class HlsNotifier { /// @param start_byte_offset is the offset of where the keyframe starts. /// @param size is the size in bytes. virtual bool NotifyKeyFrame(uint32_t stream_id, - uint64_t timestamp, + int64_t timestamp, uint64_t start_byte_offset, uint64_t size) = 0; /// @param stream_id is the value set by NotifyNewStream(). /// @param timestamp is the timestamp of the CueEvent. /// @return true on success, false otherwise. - virtual bool NotifyCueEvent(uint32_t stream_id, uint64_t timestamp) = 0; + virtual bool NotifyCueEvent(uint32_t stream_id, int64_t timestamp) = 0; /// @param stream_id is the value set by NotifyNewStream(). /// @param key_id is the key ID for the stream. diff --git a/packager/hls/base/media_playlist.cc b/packager/hls/base/media_playlist.cc index e1089448d2..04feb502a0 100644 --- a/packager/hls/base/media_playlist.cc +++ b/packager/hls/base/media_playlist.cc @@ -25,7 +25,7 @@ namespace shaka { namespace hls { namespace { -uint32_t GetTimeScale(const MediaInfo& media_info) { +int32_t GetTimeScale(const MediaInfo& media_info) { if (media_info.has_reference_time_scale()) return media_info.reference_time_scale(); @@ -34,7 +34,7 @@ uint32_t GetTimeScale(const MediaInfo& media_info) { if (media_info.has_audio_info()) return media_info.audio_info().time_scale(); - return 0u; + return 0; } std::string AdjustVideoCodec(const std::string& codec) { @@ -103,7 +103,7 @@ void AppendExtXMap(const MediaInfo& media_info, std::string* out) { std::string CreatePlaylistHeader( const MediaInfo& media_info, - uint32_t target_duration, + int32_t target_duration, HlsPlaylistType type, MediaPlaylist::MediaPlaylistStreamType stream_type, uint32_t media_sequence_number, @@ -371,7 +371,7 @@ void MediaPlaylist::SetCharacteristicsForTesting( } bool MediaPlaylist::SetMediaInfo(const MediaInfo& media_info) { - const uint32_t time_scale = GetTimeScale(media_info); + const int32_t time_scale = GetTimeScale(media_info); if (time_scale == 0) { LOG(ERROR) << "MediaInfo does not contain a valid timescale."; return false; @@ -400,7 +400,7 @@ bool MediaPlaylist::SetMediaInfo(const MediaInfo& media_info) { return true; } -void MediaPlaylist::SetSampleDuration(uint32_t sample_duration) { +void MediaPlaylist::SetSampleDuration(int32_t sample_duration) { if (media_info_.has_video_info()) media_info_.mutable_video_info()->set_frame_duration(sample_duration); } @@ -506,7 +506,7 @@ double MediaPlaylist::GetLongestSegmentDuration() const { return longest_segment_duration_seconds_; } -void MediaPlaylist::SetTargetDuration(uint32_t target_duration) { +void MediaPlaylist::SetTargetDuration(int32_t target_duration) { if (target_duration_set_) { if (target_duration_ == target_duration) return; @@ -664,7 +664,7 @@ void MediaPlaylist::SlideWindow() { hls_params_.playlist_type != HlsPlaylistType::kLive) { return; } - DCHECK_GT(time_scale_, 0u); + DCHECK_GT(time_scale_, 0); if (current_buffer_depth_ <= hls_params_.time_shift_buffer_depth) return; diff --git a/packager/hls/base/media_playlist.h b/packager/hls/base/media_playlist.h index 18d86494d4..50f45f9f7e 100644 --- a/packager/hls/base/media_playlist.h +++ b/packager/hls/base/media_playlist.h @@ -103,7 +103,7 @@ class MediaPlaylist { /// Sample duration is not available right away especially. This allows /// setting the sample duration after the Media Playlist has been initialized. /// @param sample_duration is the duration of a sample. - virtual void SetSampleDuration(uint32_t sample_duration); + virtual void SetSampleDuration(int32_t sample_duration); /// Segments must be added in order. /// @param file_name is the file name of the segment. @@ -183,7 +183,7 @@ class MediaPlaylist { /// The spec does not allow changing EXT-X-TARGETDURATION. However, this class /// has no control over the input source. /// @param target_duration is the target duration for this playlist. - virtual void SetTargetDuration(uint32_t target_duration); + virtual void SetTargetDuration(int32_t target_duration); /// @return number of channels for audio. 0 is returned for video. virtual int GetNumChannels() const; @@ -265,7 +265,7 @@ class MediaPlaylist { int discontinuity_sequence_number_ = 0; double longest_segment_duration_seconds_ = 0.0; - uint32_t time_scale_ = 0; + int32_t time_scale_ = 0; BandwidthEstimator bandwidth_estimator_; @@ -275,7 +275,7 @@ class MediaPlaylist { // See SetTargetDuration() comments. bool target_duration_set_ = false; - uint32_t target_duration_ = 0; + int32_t target_duration_ = 0; // TODO(kqyang): This could be managed better by a separate class, than having // all them managed in MediaPlaylist. diff --git a/packager/hls/base/media_playlist_unittest.cc b/packager/hls/base/media_playlist_unittest.cc index 1dce438a4f..4ef815ebad 100644 --- a/packager/hls/base/media_playlist_unittest.cc +++ b/packager/hls/base/media_playlist_unittest.cc @@ -27,7 +27,7 @@ namespace { const char kDefaultPlaylistFileName[] = "default_playlist.m3u8"; const double kTimeShiftBufferDepth = 20; -const uint64_t kTimeScale = 90000; +const int64_t kTimeScale = 90000; const uint64_t kMBytes = 1000000; const uint64_t kZeroByteOffset = 0; @@ -1002,8 +1002,8 @@ const char kIgnoredSegmentName[] = "ignored_segment_name"; const char kSegmentTemplateTime[] = "memory://$Time$.mp4"; const char kSegmentTemplateTimeUrl[] = "video/$Time$.mp4"; -const uint64_t kInitialStartTime = 0; -const uint64_t kDuration = kTimeScale; +const int64_t kInitialStartTime = 0; +const int64_t kDuration = kTimeScale; } // namespace class MediaPlaylistDeleteSegmentsTest diff --git a/packager/hls/base/mock_media_playlist.h b/packager/hls/base/mock_media_playlist.h index 11a350842a..a971dd8b74 100644 --- a/packager/hls/base/mock_media_playlist.h +++ b/packager/hls/base/mock_media_playlist.h @@ -46,7 +46,7 @@ class MockMediaPlaylist : public MediaPlaylist { MOCK_CONST_METHOD0(MaxBitrate, uint64_t()); MOCK_CONST_METHOD0(AvgBitrate, uint64_t()); MOCK_CONST_METHOD0(GetLongestSegmentDuration, double()); - MOCK_METHOD1(SetTargetDuration, void(uint32_t target_duration)); + MOCK_METHOD1(SetTargetDuration, void(int32_t target_duration)); MOCK_CONST_METHOD0(GetNumChannels, int()); MOCK_CONST_METHOD0(GetEC3JocComplexity, int()); MOCK_CONST_METHOD0(GetAC4ImsFlag, bool()); diff --git a/packager/hls/base/simple_hls_notifier.cc b/packager/hls/base/simple_hls_notifier.cc index 0867631e33..300ec0178a 100644 --- a/packager/hls/base/simple_hls_notifier.cc +++ b/packager/hls/base/simple_hls_notifier.cc @@ -345,7 +345,7 @@ bool SimpleHlsNotifier::NotifyNewStream(const MediaInfo& media_info, } bool SimpleHlsNotifier::NotifySampleDuration(uint32_t stream_id, - uint32_t sample_duration) { + int32_t sample_duration) { base::AutoLock auto_lock(lock_); auto stream_iterator = stream_map_.find(stream_id); if (stream_iterator == stream_map_.end()) { @@ -359,8 +359,8 @@ bool SimpleHlsNotifier::NotifySampleDuration(uint32_t stream_id, bool SimpleHlsNotifier::NotifyNewSegment(uint32_t stream_id, const std::string& segment_name, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t start_byte_offset, uint64_t size) { base::AutoLock auto_lock(lock_); @@ -377,8 +377,8 @@ bool SimpleHlsNotifier::NotifyNewSegment(uint32_t stream_id, start_byte_offset, size); // Update target duration. - uint32_t longest_segment_duration = - static_cast(ceil(media_playlist->GetLongestSegmentDuration())); + int32_t longest_segment_duration = + static_cast(ceil(media_playlist->GetLongestSegmentDuration())); bool target_duration_updated = false; if (longest_segment_duration > target_duration_) { target_duration_ = longest_segment_duration; @@ -409,7 +409,7 @@ bool SimpleHlsNotifier::NotifyNewSegment(uint32_t stream_id, } bool SimpleHlsNotifier::NotifyKeyFrame(uint32_t stream_id, - uint64_t timestamp, + int64_t timestamp, uint64_t start_byte_offset, uint64_t size) { base::AutoLock auto_lock(lock_); @@ -423,7 +423,7 @@ bool SimpleHlsNotifier::NotifyKeyFrame(uint32_t stream_id, return true; } -bool SimpleHlsNotifier::NotifyCueEvent(uint32_t stream_id, uint64_t timestamp) { +bool SimpleHlsNotifier::NotifyCueEvent(uint32_t stream_id, int64_t timestamp) { base::AutoLock auto_lock(lock_); auto stream_iterator = stream_map_.find(stream_id); if (stream_iterator == stream_map_.end()) { diff --git a/packager/hls/base/simple_hls_notifier.h b/packager/hls/base/simple_hls_notifier.h index abfdc08185..314ea9c765 100644 --- a/packager/hls/base/simple_hls_notifier.h +++ b/packager/hls/base/simple_hls_notifier.h @@ -50,18 +50,18 @@ class SimpleHlsNotifier : public HlsNotifier { const std::string& group_id, uint32_t* stream_id) override; bool NotifySampleDuration(uint32_t stream_id, - uint32_t sample_duration) override; + int32_t sample_duration) override; bool NotifyNewSegment(uint32_t stream_id, const std::string& segment_name, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t start_byte_offset, uint64_t size) override; bool NotifyKeyFrame(uint32_t stream_id, - uint64_t timestamp, + int64_t timestamp, uint64_t start_byte_offset, uint64_t size) override; - bool NotifyCueEvent(uint32_t container_id, uint64_t timestamp) override; + bool NotifyCueEvent(uint32_t container_id, int64_t timestamp) override; bool NotifyEncryptionUpdate( uint32_t stream_id, const std::vector& key_id, @@ -80,7 +80,7 @@ class SimpleHlsNotifier : public HlsNotifier { }; std::string master_playlist_dir_; - uint32_t target_duration_ = 0; + int32_t target_duration_ = 0; std::unique_ptr media_playlist_factory_; std::unique_ptr master_playlist_; diff --git a/packager/hls/base/simple_hls_notifier_unittest.cc b/packager/hls/base/simple_hls_notifier_unittest.cc index c498113264..896d41a06b 100644 --- a/packager/hls/base/simple_hls_notifier_unittest.cc +++ b/packager/hls/base/simple_hls_notifier_unittest.cc @@ -79,8 +79,8 @@ const double kTestTimeShiftBufferDepth = 1800.0; const char kTestPrefix[] = "http://testprefix.com/"; const char kAnyOutputDir[] = "anything"; -const uint64_t kAnyStartTime = 10; -const uint64_t kAnyDuration = 1000; +const int64_t kAnyStartTime = 10; +const int64_t kAnyDuration = 1000; const uint64_t kAnySize = 2000; const char kCencProtectionScheme[] = "cenc"; @@ -209,8 +209,8 @@ TEST_F(SimpleHlsNotifierTest, NotifyNewSegment) { EXPECT_CALL(*factory, CreateMock(_, _, _, _)) .WillOnce(Return(mock_media_playlist)); - const uint64_t kStartTime = 1328; - const uint64_t kDuration = 398407; + const int64_t kStartTime = 1328; + const int64_t kDuration = 398407; const uint64_t kSize = 6595840; const std::string segment_name = "segmentname"; EXPECT_CALL(*mock_media_playlist, @@ -218,7 +218,7 @@ TEST_F(SimpleHlsNotifierTest, NotifyNewSegment) { kDuration, 203, kSize)); const double kLongestSegmentDuration = 11.3; - const uint32_t kTargetDuration = 12; // ceil(kLongestSegmentDuration). + const int32_t kTargetDuration = 12; // ceil(kLongestSegmentDuration). EXPECT_CALL(*mock_media_playlist, GetLongestSegmentDuration()) .WillOnce(Return(kLongestSegmentDuration)); @@ -261,7 +261,7 @@ TEST_F(SimpleHlsNotifierTest, NotifyKeyFrame) { const uint32_t stream_id = SetupStream(kCencProtectionScheme, mock_media_playlist, ¬ifier); - const uint64_t kTimestamp = 12345; + const int64_t kTimestamp = 12345; const uint64_t kStartByteOffset = 888; const uint64_t kSize = 555; EXPECT_CALL(*mock_media_playlist, @@ -369,7 +369,7 @@ TEST_F(SimpleHlsNotifierTest, NotifyCueEvent) { SetupStream(kCencProtectionScheme, mock_media_playlist, ¬ifier); EXPECT_CALL(*mock_media_playlist, AddPlacementOpportunity()); - const uint64_t kCueEventTimestamp = 12345; + const int64_t kCueEventTimestamp = 12345; EXPECT_TRUE(notifier.NotifyCueEvent(stream_id, kCueEventTimestamp)); } @@ -538,8 +538,8 @@ TEST_P(LiveOrEventSimpleHlsNotifierTest, NotifyNewSegment) { EXPECT_CALL(*factory, CreateMock(_, _, _, _)) .WillOnce(Return(mock_media_playlist)); - const uint64_t kStartTime = 1328; - const uint64_t kDuration = 398407; + const int64_t kStartTime = 1328; + const int64_t kDuration = 398407; const uint64_t kSize = 6595840; const std::string segment_name = "segmentname"; EXPECT_CALL(*mock_media_playlist, @@ -547,7 +547,7 @@ TEST_P(LiveOrEventSimpleHlsNotifierTest, NotifyNewSegment) { kDuration, _, kSize)); const double kLongestSegmentDuration = 11.3; - const uint32_t kTargetDuration = 12; // ceil(kLongestSegmentDuration). + const int32_t kTargetDuration = 12; // ceil(kLongestSegmentDuration). EXPECT_CALL(*mock_media_playlist, GetLongestSegmentDuration()) .WillOnce(Return(kLongestSegmentDuration)); @@ -578,8 +578,8 @@ TEST_P(LiveOrEventSimpleHlsNotifierTest, NotifyNewSegment) { } TEST_P(LiveOrEventSimpleHlsNotifierTest, NotifyNewSegmentsWithMultipleStreams) { - const uint64_t kStartTime = 1328; - const uint64_t kDuration = 398407; + const int64_t kStartTime = 1328; + const int64_t kDuration = 398407; const uint64_t kSize = 6595840; InSequence in_sequence; @@ -619,7 +619,7 @@ TEST_P(LiveOrEventSimpleHlsNotifierTest, NotifyNewSegmentsWithMultipleStreams) { EXPECT_CALL(*mock_media_playlist1, AddSegment(_, _, _, _, _)).Times(1); const double kLongestSegmentDuration = 11.3; - const uint32_t kTargetDuration = 12; // ceil(kLongestSegmentDuration). + const int32_t kTargetDuration = 12; // ceil(kLongestSegmentDuration). EXPECT_CALL(*mock_media_playlist1, GetLongestSegmentDuration()) .WillOnce(Return(kLongestSegmentDuration)); diff --git a/packager/media/base/audio_stream_info.cc b/packager/media/base/audio_stream_info.cc index 50bf262f6d..5c5cd294dd 100644 --- a/packager/media/base/audio_stream_info.cc +++ b/packager/media/base/audio_stream_info.cc @@ -65,15 +65,31 @@ FourCC CodecToFourCC(Codec codec) { } } // namespace -AudioStreamInfo::AudioStreamInfo( - 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, uint8_t sample_bits, uint8_t num_channels, - uint32_t sampling_frequency, uint64_t seek_preroll_ns, - uint64_t codec_delay_ns, uint32_t max_bitrate, uint32_t avg_bitrate, - const std::string& language, bool is_encrypted) - : StreamInfo(kStreamAudio, track_id, time_scale, duration, codec, - codec_string, codec_config, codec_config_size, language, +AudioStreamInfo::AudioStreamInfo(int track_id, + int32_t time_scale, + int64_t duration, + Codec codec, + const std::string& codec_string, + const uint8_t* codec_config, + size_t codec_config_size, + uint8_t sample_bits, + uint8_t num_channels, + uint32_t sampling_frequency, + uint64_t seek_preroll_ns, + uint64_t codec_delay_ns, + uint32_t max_bitrate, + uint32_t avg_bitrate, + const std::string& language, + bool is_encrypted) + : StreamInfo(kStreamAudio, + track_id, + time_scale, + duration, + codec, + codec_string, + codec_config, + codec_config_size, + language, is_encrypted), sample_bits_(sample_bits), num_channels_(num_channels), diff --git a/packager/media/base/audio_stream_info.h b/packager/media/base/audio_stream_info.h index 55a547ca23..2f28207618 100644 --- a/packager/media/base/audio_stream_info.h +++ b/packager/media/base/audio_stream_info.h @@ -18,13 +18,21 @@ namespace media { class AudioStreamInfo : public StreamInfo { public: /// Construct an initialized audio stream info object. - AudioStreamInfo(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, - uint8_t sample_bits, uint8_t num_channels, - uint32_t sampling_frequency, uint64_t seek_preroll_ns, - uint64_t codec_delay_ns, uint32_t max_bitrate, - uint32_t avg_bitrate, const std::string& language, + AudioStreamInfo(int track_id, + int32_t time_scale, + int64_t duration, + Codec codec, + const std::string& codec_string, + const uint8_t* codec_config, + size_t codec_config_size, + uint8_t sample_bits, + uint8_t num_channels, + uint32_t sampling_frequency, + uint64_t seek_preroll_ns, + uint64_t codec_delay_ns, + uint32_t max_bitrate, + uint32_t avg_bitrate, + const std::string& language, bool is_encrypted); ~AudioStreamInfo() override; diff --git a/packager/media/base/audio_timestamp_helper.cc b/packager/media/base/audio_timestamp_helper.cc index 97450ee94a..fc266b250d 100644 --- a/packager/media/base/audio_timestamp_helper.cc +++ b/packager/media/base/audio_timestamp_helper.cc @@ -10,7 +10,7 @@ namespace shaka { namespace media { -AudioTimestampHelper::AudioTimestampHelper(uint32_t timescale, +AudioTimestampHelper::AudioTimestampHelper(int32_t timescale, uint32_t samples_per_second) : base_timestamp_(kNoTimestamp), frame_count_(0) { DCHECK_GT(samples_per_second, 0u); diff --git a/packager/media/base/audio_timestamp_helper.h b/packager/media/base/audio_timestamp_helper.h index b6dd7bad71..1ade86998d 100644 --- a/packager/media/base/audio_timestamp_helper.h +++ b/packager/media/base/audio_timestamp_helper.h @@ -29,8 +29,7 @@ namespace media { // accumulated frames to reach a target timestamp. class AudioTimestampHelper { public: - explicit AudioTimestampHelper(uint32_t timescale, - uint32_t samples_per_second); + explicit AudioTimestampHelper(int32_t timescale, uint32_t samples_per_second); // Sets the base timestamp to |base_timestamp| and the sets count to 0. void SetBaseTimestamp(int64_t base_timestamp); diff --git a/packager/media/base/audio_timestamp_helper_unittest.cc b/packager/media/base/audio_timestamp_helper_unittest.cc index c20a572d54..9a34a4856d 100644 --- a/packager/media/base/audio_timestamp_helper_unittest.cc +++ b/packager/media/base/audio_timestamp_helper_unittest.cc @@ -11,7 +11,7 @@ namespace shaka { namespace media { static const uint32_t kDefaultSampleRate = 44100; -static const uint32_t kTimescale = 1000000; +static const int32_t kTimescale = 1000000; class AudioTimestampHelperTest : public ::testing::Test { public: diff --git a/packager/media/base/http_key_fetcher.cc b/packager/media/base/http_key_fetcher.cc index 5cea5f3b5f..7018aec93f 100644 --- a/packager/media/base/http_key_fetcher.cc +++ b/packager/media/base/http_key_fetcher.cc @@ -24,7 +24,7 @@ constexpr size_t kBufferSize = 64 * 1024; HttpKeyFetcher::HttpKeyFetcher() : timeout_in_seconds_(0) {} -HttpKeyFetcher::HttpKeyFetcher(uint32_t timeout_in_seconds) +HttpKeyFetcher::HttpKeyFetcher(int32_t timeout_in_seconds) : timeout_in_seconds_(timeout_in_seconds) {} HttpKeyFetcher::~HttpKeyFetcher() {} diff --git a/packager/media/base/http_key_fetcher.h b/packager/media/base/http_key_fetcher.h index 7f6ccbb2fc..32365f96df 100644 --- a/packager/media/base/http_key_fetcher.h +++ b/packager/media/base/http_key_fetcher.h @@ -28,7 +28,7 @@ class HttpKeyFetcher : public KeyFetcher { HttpKeyFetcher(); /// Create a fetcher with timeout. /// @param timeout_in_seconds specifies the timeout in seconds. - HttpKeyFetcher(uint32_t timeout_in_seconds); + HttpKeyFetcher(int32_t timeout_in_seconds); ~HttpKeyFetcher() override; /// @name KeyFetcher implementation overrides. @@ -56,7 +56,7 @@ class HttpKeyFetcher : public KeyFetcher { Status FetchInternal(HttpMethod method, const std::string& url, const std::string& data, std::string* response); - const uint32_t timeout_in_seconds_; + const int32_t timeout_in_seconds_; DISALLOW_COPY_AND_ASSIGN(HttpKeyFetcher); }; diff --git a/packager/media/base/http_key_fetcher_unittest.cc b/packager/media/base/http_key_fetcher_unittest.cc index 40fce9aef0..6beabd8991 100644 --- a/packager/media/base/http_key_fetcher_unittest.cc +++ b/packager/media/base/http_key_fetcher_unittest.cc @@ -80,7 +80,7 @@ TEST(DISABLED_HttpKeyFetcherTest, UrlWithPort) { } TEST(DISABLED_HttpKeyFetcherTest, SmallTimeout) { - const uint32_t kTimeoutInSeconds = 1; + const int32_t kTimeoutInSeconds = 1; HttpKeyFetcher fetcher(kTimeoutInSeconds); std::string response; Status status = fetcher.FetchKeys(kTestUrl, kDelayTwoSecs, &response); @@ -88,7 +88,7 @@ TEST(DISABLED_HttpKeyFetcherTest, SmallTimeout) { } TEST(DISABLED_HttpKeyFetcherTest, BigTimeout) { - const uint32_t kTimeoutInSeconds = 5; + const int32_t kTimeoutInSeconds = 5; HttpKeyFetcher fetcher(kTimeoutInSeconds); std::string response; Status status = fetcher.FetchKeys(kTestUrl, kDelayTwoSecs, &response); diff --git a/packager/media/base/key_source.h b/packager/media/base/key_source.h index 750a82539e..d8721aa33f 100644 --- a/packager/media/base/key_source.h +++ b/packager/media/base/key_source.h @@ -87,7 +87,7 @@ class KeySource { /// key. Owner retains ownership, and may not be NULL. /// @return OK on success, an error status otherwise. virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, + int32_t crypto_period_duration_in_seconds, const std::string& stream_label, EncryptionKey* key) = 0; diff --git a/packager/media/base/media_handler_test_base.cc b/packager/media/base/media_handler_test_base.cc index 02d3fff2b2..37f1abad4f 100644 --- a/packager/media/base/media_handler_test_base.cc +++ b/packager/media/base/media_handler_test_base.cc @@ -14,7 +14,7 @@ namespace { const int kTrackId = 1; -const uint64_t kDuration = 10000; +const int64_t kDuration = 10000; const char kCodecString[] = "codec string"; const uint8_t kSampleBits = 1; const uint8_t kNumChannels = 2; @@ -175,25 +175,25 @@ bool MediaHandlerTestBase::IsVideoCodec(Codec codec) const { } std::unique_ptr MediaHandlerTestBase::GetVideoStreamInfo( - uint32_t time_scale) const { + int32_t time_scale) const { return GetVideoStreamInfo(time_scale, kCodecVP9, kWidth, kHeight); } std::unique_ptr MediaHandlerTestBase::GetVideoStreamInfo( - uint32_t time_scale, + int32_t time_scale, uint32_t width, uint64_t height) const { return GetVideoStreamInfo(time_scale, kCodecVP9, width, height); } std::unique_ptr MediaHandlerTestBase::GetVideoStreamInfo( - uint32_t time_scale, + int32_t time_scale, Codec codec) const { return GetVideoStreamInfo(time_scale, codec, kWidth, kHeight); } std::unique_ptr MediaHandlerTestBase::GetVideoStreamInfo( - uint32_t time_scale, + int32_t time_scale, Codec codec, uint32_t width, uint64_t height) const { @@ -205,12 +205,12 @@ std::unique_ptr MediaHandlerTestBase::GetVideoStreamInfo( } std::unique_ptr MediaHandlerTestBase::GetAudioStreamInfo( - uint32_t time_scale) const { + int32_t time_scale) const { return GetAudioStreamInfo(time_scale, kCodecAAC); } std::unique_ptr MediaHandlerTestBase::GetAudioStreamInfo( - uint32_t time_scale, + int32_t time_scale, Codec codec) const { return std::unique_ptr(new AudioStreamInfo( kTrackId, time_scale, kDuration, codec, kCodecString, kCodecConfig, @@ -254,7 +254,7 @@ std::unique_ptr MediaHandlerTestBase::GetSegmentInfo( } std::unique_ptr MediaHandlerTestBase::GetTextStreamInfo( - uint32_t timescale) const { + int32_t timescale) const { // None of this information is actually used by the text out handler. // The stream info is just needed to signal the start of the stream. return std::unique_ptr( diff --git a/packager/media/base/media_handler_test_base.h b/packager/media/base/media_handler_test_base.h index 2248e30569..a0b6fe5204 100644 --- a/packager/media/base/media_handler_test_base.h +++ b/packager/media/base/media_handler_test_base.h @@ -292,23 +292,23 @@ class MediaHandlerTestBase : public ::testing::Test { protected: bool IsVideoCodec(Codec codec) const; - std::unique_ptr GetVideoStreamInfo(uint32_t time_scale) const; + std::unique_ptr GetVideoStreamInfo(int32_t time_scale) const; - std::unique_ptr GetVideoStreamInfo(uint32_t time_scale, + std::unique_ptr GetVideoStreamInfo(int32_t time_scale, uint32_t width, uint64_t height) const; - std::unique_ptr GetVideoStreamInfo(uint32_t time_scale, + std::unique_ptr GetVideoStreamInfo(int32_t time_scale, Codec codec) const; - std::unique_ptr GetVideoStreamInfo(uint32_t time_scale, + std::unique_ptr GetVideoStreamInfo(int32_t time_scale, Codec codec, uint32_t width, uint64_t height) const; - std::unique_ptr GetAudioStreamInfo(uint32_t time_scale) const; + std::unique_ptr GetAudioStreamInfo(int32_t time_scale) const; - std::unique_ptr GetAudioStreamInfo(uint32_t time_scale, + std::unique_ptr GetAudioStreamInfo(int32_t time_scale, Codec codec) const; std::shared_ptr GetMediaSample(int64_t timestamp, @@ -325,7 +325,7 @@ class MediaHandlerTestBase : public ::testing::Test { int64_t duration, bool is_subsegment) const; - std::unique_ptr GetTextStreamInfo(uint32_t timescale) const; + std::unique_ptr GetTextStreamInfo(int32_t timescale) const; std::unique_ptr GetTextSample(const std::string& id, int64_t start, diff --git a/packager/media/base/muxer_options.h b/packager/media/base/muxer_options.h index b69d2f794b..ff24ff2664 100644 --- a/packager/media/base/muxer_options.h +++ b/packager/media/base/muxer_options.h @@ -26,7 +26,7 @@ struct MuxerOptions { // A positive value, in milliseconds, by which output timestamps are offset to // compensate for negative timestamps in the input. - uint32_t transport_stream_timestamp_offset_ms = 0; + int32_t transport_stream_timestamp_offset_ms = 0; /// Output file name. If segment_template is not specified, the Muxer /// generates this single output file with all segments concatenated; diff --git a/packager/media/base/muxer_util.cc b/packager/media/base/muxer_util.cc index 86571cb062..9a8d7f3218 100644 --- a/packager/media/base/muxer_util.cc +++ b/packager/media/base/muxer_util.cc @@ -109,7 +109,7 @@ Status ValidateSegmentTemplate(const std::string& segment_template) { } std::string GetSegmentName(const std::string& segment_template, - uint64_t segment_start_time, + int64_t segment_start_time, uint32_t segment_index, uint32_t bandwidth) { DCHECK_EQ(Status::OK, ValidateSegmentTemplate(segment_template)); diff --git a/packager/media/base/muxer_util.h b/packager/media/base/muxer_util.h index 43aa0177a2..c7524ad4ff 100644 --- a/packager/media/base/muxer_util.h +++ b/packager/media/base/muxer_util.h @@ -33,7 +33,7 @@ Status ValidateSegmentTemplate(const std::string& segment_template); /// @param bandwidth represents the bit rate, in bits/sec, of the stream. /// @return The segment name with identifier substituted. std::string GetSegmentName(const std::string& segment_template, - uint64_t segment_start_time, + int64_t segment_start_time, uint32_t segment_index, uint32_t bandwidth); diff --git a/packager/media/base/muxer_util_unittest.cc b/packager/media/base/muxer_util_unittest.cc index 7e0c14616f..4b1ce39882 100644 --- a/packager/media/base/muxer_util_unittest.cc +++ b/packager/media/base/muxer_util_unittest.cc @@ -61,7 +61,7 @@ TEST(MuxerUtilTest, ValidateSegmentTemplateWithFormatTag) { } TEST(MuxerUtilTest, GetSegmentName) { - const uint64_t kSegmentStartTime = 180180; + const int64_t kSegmentStartTime = 180180; const uint32_t kSegmentIndex = 11; const uint32_t kBandwidth = 1234; EXPECT_EQ("12", GetSegmentName("$Number$", @@ -118,7 +118,7 @@ TEST(MuxerUtilTest, GetSegmentName) { } TEST(MuxerUtilTest, GetSegmentNameWithIndexZero) { - const uint64_t kSegmentStartTime = 0; + const int64_t kSegmentStartTime = 0; const uint32_t kSegmentIndex = 0; const uint32_t kBandwidth = 0; EXPECT_EQ("1", GetSegmentName("$Number$", @@ -143,7 +143,7 @@ TEST(MuxerUtilTest, GetSegmentNameWithIndexZero) { } TEST(MuxerUtilTest, GetSegmentNameLargeTime) { - const uint64_t kSegmentStartTime = 1601599839840ULL; + const int64_t kSegmentStartTime = 1601599839840ULL; const uint32_t kSegmentIndex = 8888888; const uint32_t kBandwidth = 444444; EXPECT_EQ("1601599839840", diff --git a/packager/media/base/playready_key_source.cc b/packager/media/base/playready_key_source.cc index 125a1971dc..b83b5c6d7f 100644 --- a/packager/media/base/playready_key_source.cc +++ b/packager/media/base/playready_key_source.cc @@ -23,7 +23,7 @@ namespace media { namespace { -const uint32_t kHttpFetchTimeout = 60; // In seconds +const int32_t kHttpFetchTimeout = 60; // In seconds const std::string kAcquireLicenseRequest = "" "& key_id, return Status::OK; } -Status PlayReadyKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, - const std::string& stream_label, - EncryptionKey* key) { +Status PlayReadyKeySource::GetCryptoPeriodKey( + uint32_t crypto_period_index, + int32_t crypto_period_duration_in_seconds, + const std::string& stream_label, + EncryptionKey* key) { // TODO(robinconnell): Implement key rotation. *key = *encryption_key_; return Status::OK; diff --git a/packager/media/base/playready_key_source.h b/packager/media/base/playready_key_source.h index 036c5c25d6..3f6afff1d3 100644 --- a/packager/media/base/playready_key_source.h +++ b/packager/media/base/playready_key_source.h @@ -35,7 +35,7 @@ class PlayReadyKeySource : public KeySource { Status GetKey(const std::vector& key_id, EncryptionKey* key) override; Status GetCryptoPeriodKey(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, + int32_t crypto_period_duration_in_seconds, const std::string& stream_label, EncryptionKey* key) override; /// @} diff --git a/packager/media/base/raw_key_source.cc b/packager/media/base/raw_key_source.cc index 0eafd5a1e6..4d0e264d35 100644 --- a/packager/media/base/raw_key_source.cc +++ b/packager/media/base/raw_key_source.cc @@ -58,10 +58,11 @@ Status RawKeySource::GetKey(const std::vector& key_id, " was not found."); } -Status RawKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, - const std::string& stream_label, - EncryptionKey* key) { +Status RawKeySource::GetCryptoPeriodKey( + uint32_t crypto_period_index, + int32_t crypto_period_duration_in_seconds, + const std::string& stream_label, + EncryptionKey* key) { RETURN_IF_ERROR(GetKey(stream_label, key)); // A naive key rotation algorithm is implemented here by left rotating the diff --git a/packager/media/base/raw_key_source.h b/packager/media/base/raw_key_source.h index 619c1ed83f..18d5236213 100644 --- a/packager/media/base/raw_key_source.h +++ b/packager/media/base/raw_key_source.h @@ -30,7 +30,7 @@ class RawKeySource : public KeySource { Status GetKey(const std::vector& key_id, EncryptionKey* key) override; Status GetCryptoPeriodKey(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, + int32_t crypto_period_duration_in_seconds, const std::string& stream_label, EncryptionKey* key) override; /// @} diff --git a/packager/media/base/stream_info.cc b/packager/media/base/stream_info.cc index c62192f815..2f2eaa2dd1 100644 --- a/packager/media/base/stream_info.cc +++ b/packager/media/base/stream_info.cc @@ -33,8 +33,8 @@ std::string StreamTypeToString(StreamType type) { StreamInfo::StreamInfo(StreamType stream_type, int track_id, - uint32_t time_scale, - uint64_t duration, + int32_t time_scale, + int64_t duration, Codec codec, const std::string& codec_string, const uint8_t* codec_config, diff --git a/packager/media/base/stream_info.h b/packager/media/base/stream_info.h index e1f8e81935..4b711b4353 100644 --- a/packager/media/base/stream_info.h +++ b/packager/media/base/stream_info.h @@ -70,8 +70,8 @@ class StreamInfo { StreamInfo(StreamType stream_type, int track_id, - uint32_t time_scale, - uint64_t duration, + int32_t time_scale, + int64_t duration, Codec codec, const std::string& codec_string, const uint8_t* codec_config, @@ -95,8 +95,8 @@ class StreamInfo { StreamType stream_type() const { return stream_type_; } uint32_t track_id() const { return track_id_; } - uint32_t time_scale() const { return time_scale_; } - uint64_t duration() const { return duration_; } + int32_t time_scale() const { return time_scale_; } + int64_t duration() const { return duration_; } Codec codec() const { return codec_; } const std::string& codec_string() const { return codec_string_; } const std::vector& codec_config() const { return codec_config_; } @@ -107,7 +107,7 @@ class StreamInfo { return encryption_config_; } - void set_duration(uint64_t duration) { duration_ = duration; } + void set_duration(int64_t duration) { duration_ = duration; } void set_codec(Codec codec) { codec_ = codec; } void set_codec_config(const std::vector& data) { codec_config_ = data; @@ -129,9 +129,9 @@ class StreamInfo { StreamType stream_type_; uint32_t track_id_; // The actual time is calculated as time / time_scale_ in seconds. - uint32_t time_scale_; + int32_t time_scale_; // Duration base on time_scale. - uint64_t duration_; + int64_t duration_; Codec codec_; std::string codec_string_; std::string language_; diff --git a/packager/media/base/text_muxer.cc b/packager/media/base/text_muxer.cc index 4ba5794175..6303127504 100644 --- a/packager/media/base/text_muxer.cc +++ b/packager/media/base/text_muxer.cc @@ -76,8 +76,8 @@ Status TextMuxer::FinalizeSegment(size_t stream_id, const std::string& segment_template = options().segment_template; DCHECK(!segment_template.empty()); const uint32_t index = segment_index_++; - const uint64_t start = segment_info.start_timestamp; - const uint64_t duration = segment_info.duration; + const int64_t start = segment_info.start_timestamp; + const int64_t duration = segment_info.duration; const uint32_t bandwidth = options().bandwidth; const std::string filename = diff --git a/packager/media/base/text_muxer.h b/packager/media/base/text_muxer.h index 6ef571e13b..72c18d6917 100644 --- a/packager/media/base/text_muxer.h +++ b/packager/media/base/text_muxer.h @@ -36,8 +36,8 @@ class TextMuxer : public Muxer { /// also clear any buffered samples. virtual Status WriteToFile(const std::string& filename, uint64_t* size) = 0; - uint64_t total_duration_ms_ = 0; - uint64_t last_cue_ms_ = 0; + int64_t total_duration_ms_ = 0; + int64_t last_cue_ms_ = 0; uint32_t segment_index_ = 0; }; diff --git a/packager/media/base/text_stream_info.cc b/packager/media/base/text_stream_info.cc index 30d5103493..e424d9cd78 100644 --- a/packager/media/base/text_stream_info.cc +++ b/packager/media/base/text_stream_info.cc @@ -11,16 +11,25 @@ namespace shaka { namespace media { -TextStreamInfo::TextStreamInfo(int track_id, uint32_t time_scale, - uint64_t duration, +TextStreamInfo::TextStreamInfo(int track_id, + int32_t time_scale, + int64_t duration, Codec codec, const std::string& codec_string, - const std::string& codec_config, uint16_t width, - uint16_t height, const std::string& language) - : StreamInfo(kStreamText, track_id, time_scale, duration, codec, + const std::string& codec_config, + uint16_t width, + uint16_t height, + const std::string& language) + : StreamInfo(kStreamText, + track_id, + time_scale, + duration, + codec, codec_string, reinterpret_cast(codec_config.data()), - codec_config.size(), language, false), + codec_config.size(), + language, + false), width_(width), height_(height) {} diff --git a/packager/media/base/text_stream_info.h b/packager/media/base/text_stream_info.h index 7aa21d14d2..1ebff9f4a1 100644 --- a/packager/media/base/text_stream_info.h +++ b/packager/media/base/text_stream_info.h @@ -60,11 +60,15 @@ class TextStreamInfo : public StreamInfo { /// @param width of the text. This may be 0. /// @param height of the text. This may be 0. /// @param language is the language of this stream. This may be empty. - TextStreamInfo(int track_id, uint32_t time_scale, uint64_t duration, + TextStreamInfo(int track_id, + int32_t time_scale, + int64_t duration, Codec codec, const std::string& codec_string, - const std::string& codec_config, uint16_t width, - uint16_t height, const std::string& language); + const std::string& codec_config, + uint16_t width, + uint16_t height, + const std::string& language); ~TextStreamInfo() override; diff --git a/packager/media/base/video_stream_info.cc b/packager/media/base/video_stream_info.cc index d927f6a1ff..8efc66b8d3 100644 --- a/packager/media/base/video_stream_info.cc +++ b/packager/media/base/video_stream_info.cc @@ -39,8 +39,8 @@ std::string VideoCodecToString(Codec codec) { } // namespace VideoStreamInfo::VideoStreamInfo(int track_id, - uint32_t time_scale, - uint64_t duration, + int32_t time_scale, + int64_t duration, Codec codec, H26xStreamFormat h26x_stream_format, const std::string& codec_string, diff --git a/packager/media/base/video_stream_info.h b/packager/media/base/video_stream_info.h index 76d518fc8d..8d89d7cc84 100644 --- a/packager/media/base/video_stream_info.h +++ b/packager/media/base/video_stream_info.h @@ -28,8 +28,8 @@ class VideoStreamInfo : public StreamInfo { /// @param pixel_width is the width of the pixel. 0 if unknown. /// @param pixel_height is the height of the pixels. 0 if unknown. VideoStreamInfo(int track_id, - uint32_t time_scale, - uint64_t duration, + int32_t time_scale, + int64_t duration, Codec codec, H26xStreamFormat h26x_stream_format, const std::string& codec_string, diff --git a/packager/media/base/widevine_key_source.cc b/packager/media/base/widevine_key_source.cc index 3c9b2151b5..4a21b3362b 100644 --- a/packager/media/base/widevine_key_source.cc +++ b/packager/media/base/widevine_key_source.cc @@ -216,10 +216,11 @@ Status WidevineKeySource::GetKey(const std::vector& key_id, "Cannot find key with specified key ID"); } -Status WidevineKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, - const std::string& stream_label, - EncryptionKey* key) { +Status WidevineKeySource::GetCryptoPeriodKey( + uint32_t crypto_period_index, + int32_t crypto_period_duration_in_seconds, + const std::string& stream_label, + EncryptionKey* key) { DCHECK(key_production_thread_.HasBeenStarted()); // TODO(kqyang): This is not elegant. Consider refactoring later. { diff --git a/packager/media/base/widevine_key_source.h b/packager/media/base/widevine_key_source.h index ac16aab7f5..d9ded89fad 100644 --- a/packager/media/base/widevine_key_source.h +++ b/packager/media/base/widevine_key_source.h @@ -48,7 +48,7 @@ class WidevineKeySource : public KeySource { Status GetKey(const std::vector& key_id, EncryptionKey* key) override; Status GetCryptoPeriodKey(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, + int32_t crypto_period_duration_in_seconds, const std::string& stream_label, EncryptionKey* key) override; /// @} @@ -130,7 +130,7 @@ class WidevineKeySource : public KeySource { bool key_production_started_ = false; base::WaitableEvent start_key_production_; uint32_t first_crypto_period_index_ = 0; - uint32_t crypto_period_duration_in_seconds_ = 0; + int32_t crypto_period_duration_in_seconds_ = 0; std::vector group_id_; bool enable_entitlement_license_ = false; std::unique_ptr key_pool_; diff --git a/packager/media/chunking/chunking_handler.cc b/packager/media/chunking/chunking_handler.cc index a9686071d2..c924a746e5 100644 --- a/packager/media/chunking/chunking_handler.cc +++ b/packager/media/chunking/chunking_handler.cc @@ -88,7 +88,7 @@ Status ChunkingHandler::OnCueEvent(std::shared_ptr event) { Status ChunkingHandler::OnMediaSample( std::shared_ptr sample) { - DCHECK_NE(time_scale_, 0u) << "kStreamInfo should arrive before kMediaSample"; + DCHECK_GT(time_scale_, 0) << "kStreamInfo should arrive before kMediaSample"; const int64_t timestamp = sample->pts(); diff --git a/packager/media/chunking/chunking_handler.h b/packager/media/chunking/chunking_handler.h index 8159c8758d..5052b1bb37 100644 --- a/packager/media/chunking/chunking_handler.h +++ b/packager/media/chunking/chunking_handler.h @@ -81,7 +81,7 @@ class ChunkingHandler : public MediaHandler { base::Optional segment_start_time_; base::Optional subsegment_start_time_; int64_t max_segment_time_ = 0; - uint32_t time_scale_ = 0; + int32_t time_scale_ = 0; // The offset is applied to sample timestamps so a full segment is generated // after cue points. diff --git a/packager/media/chunking/chunking_handler_unittest.cc b/packager/media/chunking/chunking_handler_unittest.cc index e51dd21e29..7c2dc71843 100644 --- a/packager/media/chunking/chunking_handler_unittest.cc +++ b/packager/media/chunking/chunking_handler_unittest.cc @@ -20,8 +20,8 @@ namespace shaka { namespace media { namespace { const size_t kStreamIndex = 0; -const uint32_t kTimeScale0 = 800; -const uint32_t kTimeScale1 = 1000; +const int32_t kTimeScale0 = 800; +const int32_t kTimeScale1 = 1000; const int64_t kDuration = 300; const bool kKeyFrame = true; const bool kIsSubsegment = true; diff --git a/packager/media/chunking/cue_alignment_handler.cc b/packager/media/chunking/cue_alignment_handler.cc index 1d6e8eda89..fd31a5f78f 100644 --- a/packager/media/chunking/cue_alignment_handler.cc +++ b/packager/media/chunking/cue_alignment_handler.cc @@ -46,7 +46,7 @@ int64_t GetScaledTime(const StreamInfo& info, const StreamData& data) { double TimeInSeconds(const StreamInfo& info, const StreamData& data) { const int64_t scaled_time = GetScaledTime(info, data); - const uint32_t time_scale = info.time_scale(); + const int32_t time_scale = info.time_scale(); return static_cast(scaled_time) / time_scale; } @@ -55,7 +55,7 @@ double TextEndTimeInSeconds(const StreamInfo& info, const StreamData& data) { DCHECK(data.text_sample); const int64_t scaled_time = data.text_sample->EndTime(); - const uint32_t time_scale = info.time_scale(); + const int32_t time_scale = info.time_scale(); return static_cast(scaled_time) / time_scale; } diff --git a/packager/media/chunking/cue_alignment_handler_unittest.cc b/packager/media/chunking/cue_alignment_handler_unittest.cc index ff15699a4b..76b2135e5a 100644 --- a/packager/media/chunking/cue_alignment_handler_unittest.cc +++ b/packager/media/chunking/cue_alignment_handler_unittest.cc @@ -30,7 +30,7 @@ const size_t kThreeOutputs = 3; const bool kKeyFrame = true; -const uint32_t kMsTimeScale = 1000; +const int32_t kMsTimeScale = 1000; const size_t kStreamIndex = 0; } // namespace diff --git a/packager/media/chunking/text_chunker_unittest.cc b/packager/media/chunking/text_chunker_unittest.cc index 821eac3c6d..8a20e507aa 100644 --- a/packager/media/chunking/text_chunker_unittest.cc +++ b/packager/media/chunking/text_chunker_unittest.cc @@ -18,7 +18,7 @@ namespace media { namespace { const uint64_t kStreamIndex = 0; -const uint64_t kMsTimeScale = 1000u; +const int64_t kTimescaleMs = 1000; const size_t kInputs = 1; const size_t kOutputs = 1; @@ -29,8 +29,6 @@ const size_t kOutput = 0; const bool kEncrypted = true; const bool kSubSegment = true; -const uint64_t kTimescaleMs = 1000; - const char* kNoId = ""; const char* kNoPayload = ""; } // namespace @@ -83,7 +81,7 @@ TEST_F(TextChunkerTest, SegmentsStartAtFirstSample) { } ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo( - kStreamIndex, GetTextStreamInfo(kMsTimeScale)))); + kStreamIndex, GetTextStreamInfo(kTimescaleMs)))); ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample( kStreamIndex, GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload)))); @@ -128,7 +126,7 @@ TEST_F(TextChunkerTest, SampleEndingOnSegmentStart) { } ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo( - kStreamIndex, GetTextStreamInfo(kMsTimeScale)))); + kStreamIndex, GetTextStreamInfo(kTimescaleMs)))); ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample( kStreamIndex, GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload)))); @@ -188,7 +186,7 @@ TEST_F(TextChunkerTest, CreatesSegmentsForSamples) { } ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo( - kStreamIndex, GetTextStreamInfo(kMsTimeScale)))); + kStreamIndex, GetTextStreamInfo(kTimescaleMs)))); ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample( kStreamIndex, GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload)))); @@ -258,7 +256,7 @@ TEST_F(TextChunkerTest, OutputsEmptySegments) { } ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo( - kStreamIndex, GetTextStreamInfo(kMsTimeScale)))); + kStreamIndex, GetTextStreamInfo(kTimescaleMs)))); ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample( kStreamIndex, GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload)))); @@ -409,7 +407,7 @@ TEST_F(TextChunkerTest, PreservesOrder) { } ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo( - kStreamIndex, GetTextStreamInfo(kMsTimeScale)))); + kStreamIndex, GetTextStreamInfo(kTimescaleMs)))); ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample( kStreamIndex, GetTextSample(kSampleAId, kSampleAStart, kSampleAEnd, kNoPayload)))); @@ -508,7 +506,7 @@ TEST_F(TextChunkerTest, NestedSamples) { } ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromStreamInfo( - kStreamIndex, GetTextStreamInfo(kMsTimeScale)))); + kStreamIndex, GetTextStreamInfo(kTimescaleMs)))); ASSERT_OK(Input(kInput)->Dispatch(StreamData::FromTextSample( kStreamIndex, GetTextSample(kNoId, kSampleAStart, kSampleAEnd, kNoPayload)))); diff --git a/packager/media/crypto/encryption_handler.cc b/packager/media/crypto/encryption_handler.cc index 985c487f22..4b1c4e3125 100644 --- a/packager/media/crypto/encryption_handler.cc +++ b/packager/media/crypto/encryption_handler.cc @@ -279,8 +279,8 @@ Status EncryptionHandler::ProcessMediaSample( // in that case. const int64_t dts = std::max(clear_sample->dts(), static_cast(0)); const int64_t current_crypto_period_index = dts / crypto_period_duration_; - const uint32_t crypto_period_duration_in_seconds = - static_cast(encryption_params_.crypto_period_duration_in_seconds); + const int32_t crypto_period_duration_in_seconds = static_cast( + encryption_params_.crypto_period_duration_in_seconds); if (current_crypto_period_index != prev_crypto_period_index_) { EncryptionKey encryption_key; RETURN_IF_ERROR(key_source_->GetCryptoPeriodKey( diff --git a/packager/media/crypto/encryption_handler.h b/packager/media/crypto/encryption_handler.h index 3f100b390c..5f69a666bd 100644 --- a/packager/media/crypto/encryption_handler.h +++ b/packager/media/crypto/encryption_handler.h @@ -79,7 +79,7 @@ class EncryptionHandler : public MediaHandler { // Remaining clear lead in the stream's time scale. int64_t remaining_clear_lead_ = 0; // Crypto period duration in the stream's time scale. - uint64_t crypto_period_duration_ = 0; + int64_t crypto_period_duration_ = 0; // Previous crypto period index if key rotation is enabled. int64_t prev_crypto_period_index_ = -1; bool check_new_crypto_period_ = false; diff --git a/packager/media/crypto/encryption_handler_unittest.cc b/packager/media/crypto/encryption_handler_unittest.cc index 6b78c71628..3d0f26d6a7 100644 --- a/packager/media/crypto/encryption_handler_unittest.cc +++ b/packager/media/crypto/encryption_handler_unittest.cc @@ -38,7 +38,7 @@ using ::testing::ValuesIn; using ::testing::WithParamInterface; const size_t kStreamIndex = 0; -const uint32_t kTimeScale = 1000; +const int32_t kTimeScale = 1000; const char kAudioStreamLabel[] = "AUDIO"; const char kSdVideoStreamLabel[] = "SD"; @@ -66,7 +66,7 @@ class MockKeySource : public RawKeySource { Status(const std::string& stream_label, EncryptionKey* key)); MOCK_METHOD4(GetCryptoPeriodKey, Status(uint32_t crypto_period_index, - uint32_t crypto_period_duration_in_seconds, + int32_t crypto_period_duration_in_seconds, const std::string& stream_label, EncryptionKey* key)); }; diff --git a/packager/media/crypto/subsample_generator_unittest.cc b/packager/media/crypto/subsample_generator_unittest.cc index 51ffd98908..f509828b04 100644 --- a/packager/media/crypto/subsample_generator_unittest.cc +++ b/packager/media/crypto/subsample_generator_unittest.cc @@ -52,8 +52,8 @@ const uint8_t kH264CodecConfig[] = { }; const uint8_t kAV1CodecConfig[] = {0x00, 0x01, 0x02, 0x03}; const int kTrackId = 1; -const uint32_t kTimeScale = 1000; -const uint64_t kDuration = 10000; +const int32_t kTimeScale = 1000; +const int64_t kDuration = 10000; const char kCodecString[] = "codec string"; const char kLanguage[] = "eng"; const bool kEncrypted = true; diff --git a/packager/media/event/combined_muxer_listener.cc b/packager/media/event/combined_muxer_listener.cc index 6c28e26705..dd2bd4d2d7 100644 --- a/packager/media/event/combined_muxer_listener.cc +++ b/packager/media/event/combined_muxer_listener.cc @@ -35,7 +35,7 @@ void CombinedMuxerListener::OnEncryptionStart() { void CombinedMuxerListener::OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) { for (auto& listener : muxer_listeners_) { listener->OnMediaStart(muxer_options, stream_info, time_scale, @@ -43,7 +43,7 @@ void CombinedMuxerListener::OnMediaStart(const MuxerOptions& muxer_options, } } -void CombinedMuxerListener::OnSampleDurationReady(uint32_t sample_duration) { +void CombinedMuxerListener::OnSampleDurationReady(int32_t sample_duration) { for (auto& listener : muxer_listeners_) { listener->OnSampleDurationReady(sample_duration); } diff --git a/packager/media/event/combined_muxer_listener.h b/packager/media/event/combined_muxer_listener.h index 2528974ae7..776e4d37b6 100644 --- a/packager/media/event/combined_muxer_listener.h +++ b/packager/media/event/combined_muxer_listener.h @@ -34,9 +34,9 @@ class CombinedMuxerListener : public MuxerListener { void OnEncryptionStart() override; void OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) override; - void OnSampleDurationReady(uint32_t sample_duration) override; + void OnSampleDurationReady(int32_t sample_duration) override; void OnMediaEnd(const MediaRanges& media_ranges, float duration_seconds) override; void OnNewSegment(const std::string& file_name, diff --git a/packager/media/event/hls_notify_muxer_listener.cc b/packager/media/event/hls_notify_muxer_listener.cc index fdd326c4b6..c208afe151 100644 --- a/packager/media/event/hls_notify_muxer_listener.cc +++ b/packager/media/event/hls_notify_muxer_listener.cc @@ -84,7 +84,7 @@ void HlsNotifyMuxerListener::OnEncryptionStart() { void HlsNotifyMuxerListener::OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) { std::unique_ptr media_info(new MediaInfo); if (!internal::GenerateMediaInfo(muxer_options, stream_info, time_scale, @@ -125,7 +125,7 @@ void HlsNotifyMuxerListener::OnMediaStart(const MuxerOptions& muxer_options, } } -void HlsNotifyMuxerListener::OnSampleDurationReady(uint32_t sample_duration) { +void HlsNotifyMuxerListener::OnSampleDurationReady(int32_t sample_duration) { if (stream_id_) { // This happens in live mode. hls_notifier_->NotifySampleDuration(stream_id_.value(), sample_duration); diff --git a/packager/media/event/hls_notify_muxer_listener.h b/packager/media/event/hls_notify_muxer_listener.h index ed0cb8a418..69bcc5533b 100644 --- a/packager/media/event/hls_notify_muxer_listener.h +++ b/packager/media/event/hls_notify_muxer_listener.h @@ -59,9 +59,9 @@ class HlsNotifyMuxerListener : public MuxerListener { void OnEncryptionStart() override; void OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) override; - void OnSampleDurationReady(uint32_t sample_duration) override; + void OnSampleDurationReady(int32_t sample_duration) override; void OnMediaEnd(const MediaRanges& media_ranges, float duration_seconds) override; void OnNewSegment(const std::string& file_name, diff --git a/packager/media/event/hls_notify_muxer_listener_unittest.cc b/packager/media/event/hls_notify_muxer_listener_unittest.cc index d0923a8f44..d5e2869a48 100644 --- a/packager/media/event/hls_notify_muxer_listener_unittest.cc +++ b/packager/media/event/hls_notify_muxer_listener_unittest.cc @@ -39,20 +39,20 @@ class MockHlsNotifier : public hls::HlsNotifier { const std::string& group_id, uint32_t* stream_id)); MOCK_METHOD2(NotifySampleDuration, - bool(uint32_t stream_id, uint32_t sample_duration)); + bool(uint32_t stream_id, int32_t sample_duration)); MOCK_METHOD6(NotifyNewSegment, bool(uint32_t stream_id, const std::string& segment_name, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t start_byte_offset, uint64_t size)); MOCK_METHOD4(NotifyKeyFrame, bool(uint32_t stream_id, - uint64_t timestamp, + int64_t timestamp, uint64_t start_byte_offset, uint64_t size)); - MOCK_METHOD2(NotifyCueEvent, bool(uint32_t stream_id, uint64_t timestamp)); + MOCK_METHOD2(NotifyCueEvent, bool(uint32_t stream_id, int64_t timestamp)); MOCK_METHOD5( NotifyEncryptionUpdate, bool(uint32_t stream_id, @@ -75,13 +75,13 @@ const uint8_t kAnyData[] = { }; const uint64_t kSegmentStartOffset = 10000; -const uint64_t kSegmentStartTime = 19283; -const uint64_t kSegmentDuration = 98028; +const int64_t kSegmentStartTime = 19283; +const int64_t kSegmentDuration = 98028; const uint64_t kSegmentSize = 756739; -const uint64_t kCueStartTime = kSegmentStartTime; +const int64_t kCueStartTime = kSegmentStartTime; -const uint64_t kKeyFrameTimestamp = 20123; +const int64_t kKeyFrameTimestamp = 20123; const uint64_t kKeyFrameStartByteOffset = 3456; const uint64_t kKeyFrameSize = 543234; diff --git a/packager/media/event/mock_muxer_listener.h b/packager/media/event/mock_muxer_listener.h index 818fb4bcba..c402afd00e 100644 --- a/packager/media/event/mock_muxer_listener.h +++ b/packager/media/event/mock_muxer_listener.h @@ -35,10 +35,10 @@ class MockMuxerListener : public MuxerListener { MOCK_METHOD4(OnMediaStart, void(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type)); - MOCK_METHOD1(OnSampleDurationReady, void(uint32_t sample_duration)); + MOCK_METHOD1(OnSampleDurationReady, void(int32_t sample_duration)); MOCK_METHOD9(OnMediaEndMock, void(bool has_init_range, diff --git a/packager/media/event/mpd_notify_muxer_listener.cc b/packager/media/event/mpd_notify_muxer_listener.cc index 40d1b08ccb..5f7f5444ed 100644 --- a/packager/media/event/mpd_notify_muxer_listener.cc +++ b/packager/media/event/mpd_notify_muxer_listener.cc @@ -57,11 +57,10 @@ void MpdNotifyMuxerListener::OnEncryptionInfoReady( void MpdNotifyMuxerListener::OnEncryptionStart() {} -void MpdNotifyMuxerListener::OnMediaStart( - const MuxerOptions& muxer_options, - const StreamInfo& stream_info, - uint32_t time_scale, - ContainerType container_type) { +void MpdNotifyMuxerListener::OnMediaStart(const MuxerOptions& muxer_options, + const StreamInfo& stream_info, + int32_t time_scale, + ContainerType container_type) { std::unique_ptr media_info(new MediaInfo()); if (!internal::GenerateMediaInfo(muxer_options, stream_info, @@ -108,8 +107,7 @@ void MpdNotifyMuxerListener::OnMediaStart( // Record the sample duration in the media info for VOD so that OnMediaEnd, all // the information is in the media info. -void MpdNotifyMuxerListener::OnSampleDurationReady( - uint32_t sample_duration) { +void MpdNotifyMuxerListener::OnSampleDurationReady(int32_t sample_duration) { if (mpd_notifier_->dash_profile() == DashProfile::kLive) { mpd_notifier_->NotifySampleDuration(notification_id_.value(), sample_duration); diff --git a/packager/media/event/mpd_notify_muxer_listener.h b/packager/media/event/mpd_notify_muxer_listener.h index ffa84c1f86..a54999153b 100644 --- a/packager/media/event/mpd_notify_muxer_listener.h +++ b/packager/media/event/mpd_notify_muxer_listener.h @@ -42,9 +42,9 @@ class MpdNotifyMuxerListener : public MuxerListener { void OnEncryptionStart() override; void OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) override; - void OnSampleDurationReady(uint32_t sample_duration) override; + void OnSampleDurationReady(int32_t sample_duration) override; void OnMediaEnd(const MediaRanges& media_ranges, float duration_seconds) override; void OnNewSegment(const std::string& file_name, diff --git a/packager/media/event/mpd_notify_muxer_listener_unittest.cc b/packager/media/event/mpd_notify_muxer_listener_unittest.cc index 5ef272e02b..5b5e61dc00 100644 --- a/packager/media/event/mpd_notify_muxer_listener_unittest.cc +++ b/packager/media/event/mpd_notify_muxer_listener_unittest.cc @@ -279,7 +279,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnSampleDurationReady) { VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams(); std::shared_ptr video_stream_info = CreateVideoStreamInfo(video_params); - const uint32_t kSampleDuration = 1234u; + const int32_t kSampleDuration = 1234; const char kExpectedMediaInfo[] = "video_info {\n" " frame_duration: 1234\n" // Should match the constant above. @@ -303,7 +303,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnSampleDurationReady) { "media_file_name: 'test_output_file_name.mp4'\n" "media_duration_seconds: 10.5\n"; - const uint32_t kReferenceTimeScale = 1111u; // Should match the protobuf. + const int32_t kReferenceTimeScale = 1111; // Should match the protobuf. EXPECT_CALL(*notifier_, NotifyNewContainer(_, _)).Times(0); listener_->OnMediaStart(muxer_options, *video_stream_info, @@ -326,7 +326,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnSampleDurationReadySegmentList) { VideoStreamInfoParameters video_params = GetDefaultVideoStreamInfoParams(); std::shared_ptr video_stream_info = CreateVideoStreamInfo(video_params); - const uint32_t kSampleDuration = 1234u; + const int32_t kSampleDuration = 1234; const char kExpectedMediaInfo[] = "video_info {\n" " frame_duration: 1234\n" // Should match the constant above. @@ -353,7 +353,7 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnSampleDurationReadySegmentList) { " begin: 222\n" " end: 9999\n" "}\n"; - const uint32_t kReferenceTimeScale = 1111u; // Should match the protobuf. + const int32_t kReferenceTimeScale = 1111; // Should match the protobuf. EXPECT_CALL(*notifier_, NotifyNewContainer(_, _)).Times(0); listener_->OnMediaStart(muxer_options, *video_stream_info, @@ -378,11 +378,11 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnNewSegment) { std::shared_ptr video_stream_info = CreateVideoStreamInfo(video_params); - const uint64_t kStartTime1 = 0u; - const uint64_t kDuration1 = 1000u; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 1000; const uint64_t kSegmentFileSize1 = 29812u; - const uint64_t kStartTime2 = 1001u; - const uint64_t kDuration2 = 3787u; + const int64_t kStartTime2 = 1001; + const int64_t kDuration2 = 3787; const uint64_t kSegmentFileSize2 = 83743u; EXPECT_CALL(*notifier_, NotifyNewContainer(_, _)).Times(0); @@ -416,11 +416,11 @@ TEST_F(MpdNotifyMuxerListenerTest, VodOnNewSegmentSegmentList) { std::shared_ptr video_stream_info = CreateVideoStreamInfo(video_params); - const uint64_t kStartTime1 = 0u; - const uint64_t kDuration1 = 1000u; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 1000; const uint64_t kSegmentFileSize1 = 29812u; - const uint64_t kStartTime2 = 1001u; - const uint64_t kDuration2 = 3787u; + const int64_t kStartTime2 = 1001; + const int64_t kDuration2 = 3787; const uint64_t kSegmentFileSize2 = 83743u; EXPECT_CALL(*notifier_, NotifyNewContainer(_, _)).Times(0); @@ -466,11 +466,11 @@ TEST_F(MpdNotifyMuxerListenerTest, VodMultipleFiles) { std::shared_ptr video_stream_info = CreateVideoStreamInfo(video_params); - const uint64_t kStartTime1 = 0u; - const uint64_t kDuration1 = 1000u; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 1000; const uint64_t kSegmentFileSize1 = 29812u; - const uint64_t kStartTime2 = 1001u; - const uint64_t kDuration2 = 3787u; + const int64_t kStartTime2 = 1001; + const int64_t kDuration2 = 3787; const uint64_t kSegmentFileSize2 = 83743u; // Expectation for first file before OnMediaEnd. @@ -528,11 +528,11 @@ TEST_F(MpdNotifyMuxerListenerTest, VodMultipleFilesSegmentList) { std::shared_ptr video_stream_info = CreateVideoStreamInfo(video_params); - const uint64_t kStartTime1 = 0u; - const uint64_t kDuration1 = 1000u; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 1000; const uint64_t kSegmentFileSize1 = 29812u; - const uint64_t kStartTime2 = 1001u; - const uint64_t kDuration2 = 3787u; + const int64_t kStartTime2 = 1001; + const int64_t kDuration2 = 3787; const uint64_t kSegmentFileSize2 = 83743u; // Expectation for first file before OnMediaEnd. @@ -605,11 +605,11 @@ TEST_P(MpdNotifyMuxerListenerTest, LiveNoKeyRotation) { " include_mspr_pro: 1\n" "}\n"; - const uint64_t kStartTime1 = 0u; - const uint64_t kDuration1 = 1000u; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 1000; const uint64_t kSegmentFileSize1 = 29812u; - const uint64_t kStartTime2 = 1001u; - const uint64_t kDuration2 = 3787u; + const int64_t kStartTime2 = 1001; + const int64_t kDuration2 = 3787; const uint64_t kSegmentFileSize2 = 83743u; const std::vector default_key_id( kDefaultKeyId, kDefaultKeyId + arraysize(kDefaultKeyId) - 1); @@ -678,11 +678,11 @@ TEST_P(MpdNotifyMuxerListenerTest, LiveWithKeyRotation) { " include_mspr_pro: 1\n" "}\n"; - const uint64_t kStartTime1 = 0u; - const uint64_t kDuration1 = 1000u; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 1000; const uint64_t kSegmentFileSize1 = 29812u; - const uint64_t kStartTime2 = 1001u; - const uint64_t kDuration2 = 3787u; + const int64_t kStartTime2 = 1001; + const int64_t kDuration2 = 3787; const uint64_t kSegmentFileSize2 = 83743u; const std::vector default_key_id( kDefaultKeyId, kDefaultKeyId + arraysize(kDefaultKeyId) - 1); diff --git a/packager/media/event/multi_codec_muxer_listener.cc b/packager/media/event/multi_codec_muxer_listener.cc index d9ec367099..c7d182ac05 100644 --- a/packager/media/event/multi_codec_muxer_listener.cc +++ b/packager/media/event/multi_codec_muxer_listener.cc @@ -15,7 +15,7 @@ namespace media { void MultiCodecMuxerListener::OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) { size_t num_codecs = 0; for (const std::string& codec_string : diff --git a/packager/media/event/multi_codec_muxer_listener.h b/packager/media/event/multi_codec_muxer_listener.h index 1877f15f24..ad468099ac 100644 --- a/packager/media/event/multi_codec_muxer_listener.h +++ b/packager/media/event/multi_codec_muxer_listener.h @@ -27,7 +27,7 @@ class MultiCodecMuxerListener : public CombinedMuxerListener { /// @{ void OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) override; /// @} diff --git a/packager/media/event/multi_codec_muxer_listener_unittest.cc b/packager/media/event/multi_codec_muxer_listener_unittest.cc index acce6036b9..4ac780cac7 100644 --- a/packager/media/event/multi_codec_muxer_listener_unittest.cc +++ b/packager/media/event/multi_codec_muxer_listener_unittest.cc @@ -23,10 +23,10 @@ using ::testing::StrictMock; namespace { -const uint64_t kSegmentStartTime = 19283; -const uint64_t kSegmentDuration = 98028; +const int64_t kSegmentStartTime = 19283; +const int64_t kSegmentDuration = 98028; const uint64_t kSegmentSize = 756739; -const uint32_t kTimescale = 90000; +const int32_t kTimescale = 90000; MuxerListener::ContainerType kContainer = MuxerListener::kContainerMpeg2ts; } // namespace diff --git a/packager/media/event/muxer_listener.h b/packager/media/event/muxer_listener.h index 65946c124e..f444f81fef 100644 --- a/packager/media/event/muxer_listener.h +++ b/packager/media/event/muxer_listener.h @@ -97,12 +97,12 @@ class MuxerListener { /// @param container_type is the container of this media. virtual void OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) = 0; /// Called when the average sample duration of the media is determined. /// @param sample_duration in timescale of the media. - virtual void OnSampleDurationReady(uint32_t sample_duration) = 0; + virtual void OnSampleDurationReady(int32_t sample_duration) = 0; /// Called when all files are written out and the muxer object does not output /// any more files. diff --git a/packager/media/event/muxer_listener_internal.cc b/packager/media/event/muxer_listener_internal.cc index 336737c1c3..e71d0ec97c 100644 --- a/packager/media/event/muxer_listener_internal.cc +++ b/packager/media/event/muxer_listener_internal.cc @@ -226,7 +226,7 @@ MediaInfo GetCompatibleComparisonMediaInfo(const MediaInfo& media_info) { bool GenerateMediaInfo(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t reference_time_scale, + int32_t reference_time_scale, MuxerListener::ContainerType container_type, MediaInfo* media_info) { DCHECK(media_info); diff --git a/packager/media/event/muxer_listener_internal.h b/packager/media/event/muxer_listener_internal.h index ab250904a9..aa8d068f34 100644 --- a/packager/media/event/muxer_listener_internal.h +++ b/packager/media/event/muxer_listener_internal.h @@ -29,7 +29,7 @@ namespace internal { /// @return true on success, false otherwise. bool GenerateMediaInfo(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t reference_time_scale_, + int32_t reference_time_scale_, MuxerListener::ContainerType container_type, MediaInfo* media_info); diff --git a/packager/media/event/muxer_listener_internal_unittest.cc b/packager/media/event/muxer_listener_internal_unittest.cc index 143734805f..97cc6a3ac9 100644 --- a/packager/media/event/muxer_listener_internal_unittest.cc +++ b/packager/media/event/muxer_listener_internal_unittest.cc @@ -15,7 +15,7 @@ namespace shaka { namespace media { namespace internal { namespace { -const uint32_t kReferenceTimeScale = 1000; +const int32_t kReferenceTimeScale = 1000; } // namespace class MuxerListenerInternalTest : public ::testing::Test {}; diff --git a/packager/media/event/muxer_listener_test_helper.cc b/packager/media/event/muxer_listener_test_helper.cc index 3eed87415e..8441b6289a 100644 --- a/packager/media/event/muxer_listener_test_helper.cc +++ b/packager/media/event/muxer_listener_test_helper.cc @@ -29,8 +29,8 @@ std::shared_ptr CreateVideoStreamInfo( VideoStreamInfoParameters GetDefaultVideoStreamInfoParams() { const int kTrackId = 0; - const uint32_t kTimeScale = 10; - const uint64_t kVideoStreamDuration = 200; + const int32_t kTimeScale = 10; + const int64_t kVideoStreamDuration = 200; const Codec kH264Codec = kCodecH264; const char* kCodecString = "avc1.010101"; const char* kLanuageUndefined = "und"; diff --git a/packager/media/event/muxer_listener_test_helper.h b/packager/media/event/muxer_listener_test_helper.h index d1c49a4d16..f005a9b86f 100644 --- a/packager/media/event/muxer_listener_test_helper.h +++ b/packager/media/event/muxer_listener_test_helper.h @@ -70,7 +70,7 @@ const char kExpectedDefaultMediaInfoSubsegmentRange[] = " end: 9999\n" "}\n"; -const uint32_t kDefaultReferenceTimeScale = 1000u; +const int32_t kDefaultReferenceTimeScale = 1000; // Struct that gets passed for to CreateVideoStreamInfo() to create a // StreamInfo instance. Useful for generating multiple VideoStreamInfo with @@ -79,8 +79,8 @@ struct VideoStreamInfoParameters { VideoStreamInfoParameters(); ~VideoStreamInfoParameters(); int track_id; - uint32_t time_scale; - uint64_t duration; + int32_t time_scale; + int64_t duration; Codec codec; std::string codec_string; std::string language; @@ -95,8 +95,8 @@ struct VideoStreamInfoParameters { struct OnNewSegmentParameters { std::string file_name; - uint64_t start_time; - uint64_t duration; + int64_t start_time; + int64_t duration; uint64_t segment_file_size; }; diff --git a/packager/media/event/vod_media_info_dump_muxer_listener.cc b/packager/media/event/vod_media_info_dump_muxer_listener.cc index 2259408f7b..5db9d01e75 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener.cc +++ b/packager/media/event/vod_media_info_dump_muxer_listener.cc @@ -46,7 +46,7 @@ void VodMediaInfoDumpMuxerListener::OnEncryptionInfoReady( void VodMediaInfoDumpMuxerListener::OnMediaStart( const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) { DCHECK(muxer_options.segment_template.empty()); media_info_.reset(new MediaInfo()); @@ -68,7 +68,7 @@ void VodMediaInfoDumpMuxerListener::OnMediaStart( void VodMediaInfoDumpMuxerListener::OnEncryptionStart() {} void VodMediaInfoDumpMuxerListener::OnSampleDurationReady( - uint32_t sample_duration) { + int32_t sample_duration) { // Assume one VideoInfo. if (media_info_->has_video_info()) { media_info_->mutable_video_info()->set_frame_duration(sample_duration); diff --git a/packager/media/event/vod_media_info_dump_muxer_listener.h b/packager/media/event/vod_media_info_dump_muxer_listener.h index 6b43b1964a..30873ef2e2 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener.h +++ b/packager/media/event/vod_media_info_dump_muxer_listener.h @@ -41,9 +41,9 @@ class VodMediaInfoDumpMuxerListener : public MuxerListener { void OnEncryptionStart() override; void OnMediaStart(const MuxerOptions& muxer_options, const StreamInfo& stream_info, - uint32_t time_scale, + int32_t time_scale, ContainerType container_type) override; - void OnSampleDurationReady(uint32_t sample_duration) override; + void OnSampleDurationReady(int32_t sample_duration) override; void OnMediaEnd(const MediaRanges& media_ranges, float duration_seconds) override; void OnNewSegment(const std::string& file_name, diff --git a/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc b/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc index a284dd1786..8d9e4bdd96 100644 --- a/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc +++ b/packager/media/event/vod_media_info_dump_muxer_listener_unittest.cc @@ -88,7 +88,7 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test { bool enable_encryption) { MuxerOptions muxer_options; SetDefaultMuxerOptions(&muxer_options); - const uint32_t kReferenceTimeScale = 1000; + const int32_t kReferenceTimeScale = 1000; if (enable_encryption) { std::vector bogus_default_key_id( kBogusDefaultKeyId, diff --git a/packager/media/formats/mp2t/es_parser_h26x.cc b/packager/media/formats/mp2t/es_parser_h26x.cc index 92a8d35942..c0b4672dc7 100644 --- a/packager/media/formats/mp2t/es_parser_h26x.cc +++ b/packager/media/formats/mp2t/es_parser_h26x.cc @@ -326,7 +326,7 @@ bool EsParserH26x::EmitFrame(int64_t access_unit_pos, const int64_t kArbitrarySmallDuration = 0.001 * kMpeg2Timescale; // 1ms. pending_sample_->set_duration(kArbitrarySmallDuration); } else { - uint64_t sample_duration = media_sample->dts() - pending_sample_->dts(); + int64_t sample_duration = media_sample->dts() - pending_sample_->dts(); pending_sample_->set_duration(sample_duration); const int kArbitraryGapScale = 10; diff --git a/packager/media/formats/mp2t/es_parser_h26x.h b/packager/media/formats/mp2t/es_parser_h26x.h index 26c85248a7..921b326d43 100644 --- a/packager/media/formats/mp2t/es_parser_h26x.h +++ b/packager/media/formats/mp2t/es_parser_h26x.h @@ -127,7 +127,7 @@ class EsParserH26x : public EsParser { // Frame for which we do not yet have a duration. std::shared_ptr pending_sample_; - uint64_t pending_sample_duration_ = 0; + int64_t pending_sample_duration_ = 0; // Indicates whether waiting for first key frame. bool waiting_for_key_frame_ = true; diff --git a/packager/media/formats/mp2t/mp2t_common.h b/packager/media/formats/mp2t/mp2t_common.h index 40cdd9b45c..787b5da8c6 100644 --- a/packager/media/formats/mp2t/mp2t_common.h +++ b/packager/media/formats/mp2t/mp2t_common.h @@ -22,7 +22,7 @@ namespace shaka { namespace media { -const uint32_t kMpeg2Timescale = 90000; +const int32_t kMpeg2Timescale = 90000; } // namespace media } // namespace shaka diff --git a/packager/media/formats/mp2t/pes_packet_generator.cc b/packager/media/formats/mp2t/pes_packet_generator.cc index facaff2638..15d904e79c 100644 --- a/packager/media/formats/mp2t/pes_packet_generator.cc +++ b/packager/media/formats/mp2t/pes_packet_generator.cc @@ -31,7 +31,7 @@ const double kTsTimescale = 90000.0; } // namespace PesPacketGenerator::PesPacketGenerator( - uint32_t transport_stream_timestamp_offset) + int32_t transport_stream_timestamp_offset) : transport_stream_timestamp_offset_(transport_stream_timestamp_offset) {} PesPacketGenerator::~PesPacketGenerator() {} diff --git a/packager/media/formats/mp2t/pes_packet_generator.h b/packager/media/formats/mp2t/pes_packet_generator.h index 5847e83b51..3b34546f69 100644 --- a/packager/media/formats/mp2t/pes_packet_generator.h +++ b/packager/media/formats/mp2t/pes_packet_generator.h @@ -31,7 +31,7 @@ class PesPacketGenerator { /// @param transport_stream_timestamp_offset is the offset to be applied to /// sample timestamps to compensate for possible negative timestamps in /// the input. - explicit PesPacketGenerator(uint32_t transport_stream_timestamp_offset); + explicit PesPacketGenerator(int32_t transport_stream_timestamp_offset); virtual ~PesPacketGenerator(); /// Initialize the object. This clears the internal state first so any @@ -65,7 +65,7 @@ class PesPacketGenerator { StreamType stream_type_; - const uint32_t transport_stream_timestamp_offset_ = 0; + const int32_t transport_stream_timestamp_offset_ = 0; // Calculated by 90000 / input stream's timescale. This is used to scale the // timestamps. double timescale_scale_ = 0.0; diff --git a/packager/media/formats/mp2t/pes_packet_generator_unittest.cc b/packager/media/formats/mp2t/pes_packet_generator_unittest.cc index 05656729ed..52ae00b77d 100644 --- a/packager/media/formats/mp2t/pes_packet_generator_unittest.cc +++ b/packager/media/formats/mp2t/pes_packet_generator_unittest.cc @@ -36,7 +36,7 @@ using ::testing::SetArgPointee; namespace { -const uint32_t kZeroTransportStreamTimestampOffset = 0; +const int32_t kZeroTransportStreamTimestampOffset = 0; // Bogus data for testing. const uint8_t kAnyData[] = { @@ -75,8 +75,8 @@ const uint8_t kVideoExtraData[] = { const uint8_t kAudioExtraData[] = {0x12, 0x10}; const int kTrackId = 0; -const uint32_t kTimeScale = 90000; -const uint64_t kDuration = 180000; +const int32_t kTimeScale = 90000; +const int64_t kDuration = 180000; const char kCodecString[] = "avc1"; const char kLanguage[] = "eng"; const uint32_t kWidth = 1280; @@ -198,7 +198,7 @@ TEST_F(PesPacketGeneratorTest, AddVideoSample) { std::shared_ptr sample = MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame); - const uint32_t kPts = 12345; + const int32_t kPts = 12345; const uint32_t kDts = 12300; sample->set_pts(kPts); sample->set_dts(kDts); @@ -236,7 +236,7 @@ TEST_F(PesPacketGeneratorTest, AddEncryptedVideoSample) { std::shared_ptr sample = MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame); - const uint32_t kPts = 12345; + const int32_t kPts = 12345; const uint32_t kDts = 12300; sample->set_pts(kPts); sample->set_dts(kDts); @@ -352,7 +352,7 @@ TEST_F(PesPacketGeneratorTest, AddAudioSampleFailedToConvert) { // Because TS has to use 90000 as its timescale, make sure that the timestamps // are scaled. TEST_F(PesPacketGeneratorTest, TimeStampScaling) { - const uint32_t kTestTimescale = 1000; + const int32_t kTestTimescale = 1000; std::shared_ptr stream_info(new VideoStreamInfo( kTrackId, kTestTimescale, kDuration, kH264Codec, H26xStreamFormat::kAnnexbByteStream, kCodecString, kVideoExtraData, @@ -365,7 +365,7 @@ TEST_F(PesPacketGeneratorTest, TimeStampScaling) { std::shared_ptr sample = MediaSample::CopyFrom(kAnyData, arraysize(kAnyData), kIsKeyFrame); - const uint32_t kPts = 5000; + const int32_t kPts = 5000; const uint32_t kDts = 4000; sample->set_pts(kPts); sample->set_dts(kDts); diff --git a/packager/media/formats/mp2t/ts_muxer.cc b/packager/media/formats/mp2t/ts_muxer.cc index b3be39611b..8875f48a69 100644 --- a/packager/media/formats/mp2t/ts_muxer.cc +++ b/packager/media/formats/mp2t/ts_muxer.cc @@ -11,7 +11,7 @@ namespace media { namespace mp2t { namespace { -const uint32_t kTsTimescale = 90000; +const int32_t kTsTimescale = 90000; } // namespace TsMuxer::TsMuxer(const MuxerOptions& muxer_options) : Muxer(muxer_options) {} diff --git a/packager/media/formats/mp2t/ts_segmenter.cc b/packager/media/formats/mp2t/ts_segmenter.cc index 78b2bafd0c..9f461eee1d 100644 --- a/packager/media/formats/mp2t/ts_segmenter.cc +++ b/packager/media/formats/mp2t/ts_segmenter.cc @@ -163,8 +163,7 @@ Status TsSegmenter::WritePesPackets() { return Status::OK; } -Status TsSegmenter::FinalizeSegment(uint64_t start_timestamp, - uint64_t duration) { +Status TsSegmenter::FinalizeSegment(int64_t start_timestamp, int64_t duration) { if (!pes_packet_generator_->Flush()) { return Status(error::MUXER_FAILURE, "Failed to flush PesPacketGenerator."); } diff --git a/packager/media/formats/mp2t/ts_segmenter.h b/packager/media/formats/mp2t/ts_segmenter.h index 365bc57676..6b012b7fcf 100644 --- a/packager/media/formats/mp2t/ts_segmenter.h +++ b/packager/media/formats/mp2t/ts_segmenter.h @@ -58,7 +58,7 @@ class TsSegmenter { // TODO(kqyang): Remove the usage of segment start timestamp and duration in // xx_segmenter, which could cause confusions on which is the source of truth // as the segment start timestamp and duration could be tracked locally. - Status FinalizeSegment(uint64_t start_timestamp, uint64_t duration); + Status FinalizeSegment(int64_t start_timestamp, int64_t duration); /// Only for testing. void InjectTsWriterForTesting(std::unique_ptr writer); @@ -83,7 +83,7 @@ class TsSegmenter { Codec codec_ = kUnknownCodec; std::vector audio_codec_config_; - const uint32_t transport_stream_timestamp_offset_ = 0; + const int32_t transport_stream_timestamp_offset_ = 0; // Scale used to scale the input stream to TS's timesccale (which is 90000). // Used for calculating the duration in seconds fo the current segment. double timescale_scale_ = 1.0; diff --git a/packager/media/formats/mp2t/ts_segmenter_unittest.cc b/packager/media/formats/mp2t/ts_segmenter_unittest.cc index 61f2289d77..83116186fd 100644 --- a/packager/media/formats/mp2t/ts_segmenter_unittest.cc +++ b/packager/media/formats/mp2t/ts_segmenter_unittest.cc @@ -36,9 +36,9 @@ const uint8_t kExtraData[] = { 0x00, }; const int kTrackId = 0; -const uint32_t kZeroTransportStreamTimestampOffset = 0; -const uint32_t kTimeScale = 90000; -const uint64_t kDuration = 180000; +const int32_t kZeroTransportStreamTimestampOffset = 0; +const int32_t kTimeScale = 90000; +const int64_t kDuration = 180000; const char kCodecString[] = "avc1"; const char kLanguage[] = "eng"; const uint32_t kWidth = 1280; @@ -181,7 +181,7 @@ TEST_F(TsSegmenterTest, AddSample) { 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; + const int32_t kInputTimescale = 1001; std::shared_ptr stream_info(new VideoStreamInfo( kTrackId, kInputTimescale, kDuration, kH264Codec, H26xStreamFormat::kAnnexbByteStream, kCodecString, kExtraData, @@ -194,7 +194,7 @@ TEST_F(TsSegmenterTest, PassedSegmentDuration) { MockMuxerListener mock_listener; TsSegmenter segmenter(options, &mock_listener); - const uint32_t kFirstPts = 1000; + const int32_t kFirstPts = 1000; EXPECT_CALL(*mock_pes_packet_generator_, Initialize(_)) .WillOnce(Return(true)); diff --git a/packager/media/formats/mp4/decoding_time_iterator.cc b/packager/media/formats/mp4/decoding_time_iterator.cc index e76f9bc92b..5bd12476f9 100644 --- a/packager/media/formats/mp4/decoding_time_iterator.cc +++ b/packager/media/formats/mp4/decoding_time_iterator.cc @@ -37,12 +37,12 @@ bool DecodingTimeIterator::IsValid() const { sample_index_ < iterator_->sample_count; } -uint64_t DecodingTimeIterator::Duration(uint32_t start_sample, - uint32_t end_sample) const { +int64_t DecodingTimeIterator::Duration(uint32_t start_sample, + uint32_t end_sample) const { DCHECK_LE(start_sample, end_sample); uint32_t current_sample = 0; uint32_t prev_sample = 0; - uint64_t duration = 0; + int64_t duration = 0; std::vector::const_iterator it = decoding_time_table_.begin(); for (; it != decoding_time_table_.end(); ++it) { current_sample += it->sample_count; diff --git a/packager/media/formats/mp4/decoding_time_iterator.h b/packager/media/formats/mp4/decoding_time_iterator.h index 8b388191e0..c974c17d6b 100644 --- a/packager/media/formats/mp4/decoding_time_iterator.h +++ b/packager/media/formats/mp4/decoding_time_iterator.h @@ -40,7 +40,7 @@ class DecodingTimeIterator { uint32_t sample_delta() const { return iterator_->sample_delta; } /// @return Duration from start_sample to end_sample, both 1-based, inclusive. - uint64_t Duration(uint32_t start_sample, uint32_t end_sample) const; + int64_t Duration(uint32_t start_sample, uint32_t end_sample) const; /// @return Total number of samples in the table. uint32_t NumSamples() const; diff --git a/packager/media/formats/mp4/decoding_time_iterator_unittest.cc b/packager/media/formats/mp4/decoding_time_iterator_unittest.cc index c78826c600..b819740e43 100644 --- a/packager/media/formats/mp4/decoding_time_iterator_unittest.cc +++ b/packager/media/formats/mp4/decoding_time_iterator_unittest.cc @@ -19,7 +19,7 @@ class DecodingTimeIteratorTest : public testing::Test { public: DecodingTimeIteratorTest() { // Build decoding time table from kDecodingTimes. - uint32_t decoding_time = 0; + int32_t decoding_time = 0; uint32_t length = sizeof(kDecodingTimes) / sizeof(DecodingTime); for (uint32_t i = 0; i < length; ++i) { for (uint32_t j = 0; j < kDecodingTimes[i].sample_count; ++j) { diff --git a/packager/media/formats/mp4/fragmenter.cc b/packager/media/formats/mp4/fragmenter.cc index 7154c63924..1905594c26 100644 --- a/packager/media/formats/mp4/fragmenter.cc +++ b/packager/media/formats/mp4/fragmenter.cc @@ -90,8 +90,7 @@ Status Fragmenter::AddSample(const MediaSample& sample) { if (stream_info_->stream_type() == StreamType::kStreamVideo && sample.is_key_frame()) { - key_frame_infos_.push_back( - {static_cast(pts), data_->Size(), sample.data_size()}); + key_frame_infos_.push_back({pts, data_->Size(), sample.data_size()}); } data_->AppendArray(sample.data(), sample.data_size()); diff --git a/packager/media/formats/mp4/fragmenter.h b/packager/media/formats/mp4/fragmenter.h index f9a627036a..e57ca11543 100644 --- a/packager/media/formats/mp4/fragmenter.h +++ b/packager/media/formats/mp4/fragmenter.h @@ -59,9 +59,9 @@ class Fragmenter { void ClearFragmentFinalized() { fragment_finalized_ = false; } - uint64_t fragment_duration() const { return fragment_duration_; } - uint64_t first_sap_time() const { return first_sap_time_; } - uint64_t earliest_presentation_time() const { + int64_t fragment_duration() const { return fragment_duration_; } + int64_t first_sap_time() const { return first_sap_time_; } + int64_t earliest_presentation_time() const { return earliest_presentation_time_; } bool fragment_initialized() const { return fragment_initialized_; } diff --git a/packager/media/formats/mp4/key_frame_info.h b/packager/media/formats/mp4/key_frame_info.h index fc9f249e19..7acd5d8e0f 100644 --- a/packager/media/formats/mp4/key_frame_info.h +++ b/packager/media/formats/mp4/key_frame_info.h @@ -15,7 +15,7 @@ namespace mp4 { /// Tracks key frame information. struct KeyFrameInfo { - uint64_t timestamp; + int64_t timestamp; uint64_t start_byte_offset; uint64_t size; }; diff --git a/packager/media/formats/mp4/mp4_media_parser.cc b/packager/media/formats/mp4/mp4_media_parser.cc index e22b91a9b6..5f949871c7 100644 --- a/packager/media/formats/mp4/mp4_media_parser.cc +++ b/packager/media/formats/mp4/mp4_media_parser.cc @@ -39,9 +39,9 @@ namespace media { namespace mp4 { namespace { -uint64_t Rescale(uint64_t time_in_old_scale, - uint32_t old_scale, - uint32_t new_scale) { +int64_t Rescale(int64_t time_in_old_scale, + int32_t old_scale, + int32_t new_scale) { return (static_cast(time_in_old_scale) / old_scale) * new_scale; } @@ -386,10 +386,10 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) { for (std::vector::const_iterator track = moov_->tracks.begin(); track != moov_->tracks.end(); ++track) { - const uint32_t timescale = track->media.header.timescale; + const int32_t timescale = track->media.header.timescale; // Calculate duration (based on timescale). - uint64_t duration = 0; + int64_t duration = 0; if (track->media.header.duration > 0) { duration = track->media.header.duration; } else if (moov_->extends.header.fragment_duration > 0) { diff --git a/packager/media/formats/mp4/mp4_muxer.cc b/packager/media/formats/mp4/mp4_muxer.cc index 3de400d38b..7237b4472a 100644 --- a/packager/media/formats/mp4/mp4_muxer.cc +++ b/packager/media/formats/mp4/mp4_muxer.cc @@ -655,7 +655,7 @@ void MP4Muxer::FireOnMediaStartEvent() { } DCHECK(!streams().empty()) << "Media started without a stream."; - const uint32_t timescale = segmenter_->GetReferenceTimeScale(); + const int32_t timescale = segmenter_->GetReferenceTimeScale(); muxer_listener()->OnMediaStart(options(), *streams().front(), timescale, MuxerListener::kContainerMp4); } diff --git a/packager/media/formats/mp4/multi_segment_segmenter.cc b/packager/media/formats/mp4/multi_segment_segmenter.cc index cf12e4c170..9caf1f8e69 100644 --- a/packager/media/formats/mp4/multi_segment_segmenter.cc +++ b/packager/media/formats/mp4/multi_segment_segmenter.cc @@ -148,7 +148,7 @@ Status MultiSegmentSegmenter::WriteSegment() { ", possibly file permission issue or running out of disk space."); } - uint64_t segment_duration = 0; + int64_t segment_duration = 0; // ISO/IEC 23009-1:2012: the value shall be identical to sum of the the // values of all Subsegment_duration fields in the first ‘sidx’ box. for (size_t i = 0; i < sidx()->references.size(); ++i) diff --git a/packager/media/formats/mp4/segmenter.cc b/packager/media/formats/mp4/segmenter.cc index cce500dea4..65d81e8306 100644 --- a/packager/media/formats/mp4/segmenter.cc +++ b/packager/media/formats/mp4/segmenter.cc @@ -28,9 +28,9 @@ namespace mp4 { namespace { -uint64_t Rescale(uint64_t time_in_old_scale, - uint32_t old_scale, - uint32_t new_scale) { +int64_t Rescale(int64_t time_in_old_scale, + int32_t old_scale, + int32_t new_scale) { return static_cast(time_in_old_scale) / old_scale * new_scale; } @@ -111,10 +111,11 @@ Status Segmenter::Finalize() { // file for VOD and static live case only. moov_->extends.header.fragment_duration = 0; for (size_t i = 0; i < stream_durations_.size(); ++i) { - uint64_t duration = + int64_t duration = Rescale(stream_durations_[i], moov_->tracks[i].media.header.timescale, moov_->header.timescale); - if (duration > moov_->extends.header.fragment_duration) + if (duration > + static_cast(moov_->extends.header.fragment_duration)) moov_->extends.header.fragment_duration = duration; } return DoFinalize(); @@ -234,12 +235,12 @@ Status Segmenter::FinalizeSegment(size_t stream_id, return Status::OK; } -uint32_t Segmenter::GetReferenceTimeScale() const { +int32_t Segmenter::GetReferenceTimeScale() const { return moov_->header.timescale; } double Segmenter::GetDuration() const { - uint64_t duration = moov_->extends.header.fragment_duration; + int64_t duration = moov_->extends.header.fragment_duration; if (duration == 0) { // Handling the case where this is not properly initialized. return 0.0; diff --git a/packager/media/formats/mp4/segmenter.h b/packager/media/formats/mp4/segmenter.h index 724c12ef6f..9b592299bc 100644 --- a/packager/media/formats/mp4/segmenter.h +++ b/packager/media/formats/mp4/segmenter.h @@ -91,14 +91,14 @@ class Segmenter { // Otherwise, a vector of ranges for the media segments are returned. virtual std::vector GetSegmentRanges() = 0; - uint32_t GetReferenceTimeScale() const; + int32_t GetReferenceTimeScale() const; /// @return The total length, in seconds, of segmented media files. double GetDuration() const; /// @return The sample duration in the timescale of the media. /// Returns 0 if no samples are added yet. - uint32_t sample_duration() const { return sample_duration_; } + int32_t sample_duration() const { return sample_duration_; } protected: /// Update segmentation progress using ProgressListener. @@ -144,7 +144,7 @@ class Segmenter { ProgressListener* progress_listener_ = nullptr; uint64_t progress_target_ = 0u; uint64_t accumulated_progress_ = 0u; - uint32_t sample_duration_ = 0u; + int32_t sample_duration_ = 0; std::vector stream_durations_; std::vector key_frame_infos_; diff --git a/packager/media/formats/mp4/single_segment_segmenter.cc b/packager/media/formats/mp4/single_segment_segmenter.cc index 88e0c40a1a..f717484409 100644 --- a/packager/media/formats/mp4/single_segment_segmenter.cc +++ b/packager/media/formats/mp4/single_segment_segmenter.cc @@ -174,7 +174,7 @@ Status SingleSegmentSegmenter::DoFinalizeSegment() { // reference, which contains all the fragments in sidx(). std::vector& refs = sidx()->references; SegmentReference& vod_ref = refs[0]; - uint64_t first_sap_time = + int64_t first_sap_time = refs[0].sap_delta_time + refs[0].earliest_presentation_time; for (uint32_t i = 1; i < refs.size(); ++i) { vod_ref.referenced_size += refs[i].referenced_size; diff --git a/packager/media/formats/mp4/track_run_iterator.cc b/packager/media/formats/mp4/track_run_iterator.cc index 1fc60d20db..0e7d5485a1 100644 --- a/packager/media/formats/mp4/track_run_iterator.cc +++ b/packager/media/formats/mp4/track_run_iterator.cc @@ -26,8 +26,8 @@ namespace { const int64_t kInvalidOffset = std::numeric_limits::max(); int64_t Rescale(int64_t time_in_old_scale, - uint32_t old_scale, - uint32_t new_scale) { + int32_t old_scale, + int32_t new_scale) { return (static_cast(time_in_old_scale) / old_scale) * new_scale; } diff --git a/packager/media/formats/packed_audio/packed_audio_segmenter.cc b/packager/media/formats/packed_audio/packed_audio_segmenter.cc index d6628dcd61..ea7d042225 100644 --- a/packager/media/formats/packed_audio/packed_audio_segmenter.cc +++ b/packager/media/formats/packed_audio/packed_audio_segmenter.cc @@ -17,7 +17,7 @@ namespace shaka { namespace media { namespace { -std::string TimestampToString(uint64_t timestamp) { +std::string TimestampToString(int64_t timestamp) { // https://tools.ietf.org/html/rfc8216 The ID3 payload MUST be a 33-bit MPEG-2 // Program Elementary Stream timestamp expressed as a big-endian eight-octet // number, with the upper 31 bits set to zero. @@ -30,7 +30,7 @@ std::string TimestampToString(uint64_t timestamp) { } // namespace PackedAudioSegmenter::PackedAudioSegmenter( - uint32_t transport_stream_timestamp_offset) + int32_t transport_stream_timestamp_offset) : transport_stream_timestamp_offset_(transport_stream_timestamp_offset) {} PackedAudioSegmenter::~PackedAudioSegmenter() = default; diff --git a/packager/media/formats/packed_audio/packed_audio_segmenter.h b/packager/media/formats/packed_audio/packed_audio_segmenter.h index b7b48c4754..77b3fbc73a 100644 --- a/packager/media/formats/packed_audio/packed_audio_segmenter.h +++ b/packager/media/formats/packed_audio/packed_audio_segmenter.h @@ -42,7 +42,7 @@ class PackedAudioSegmenter { /// @param transport_stream_timestamp_offset is the offset to be applied to /// sample timestamps to compensate for possible negative timestamps in /// the input. - explicit PackedAudioSegmenter(uint32_t transport_stream_timestamp_offset); + explicit PackedAudioSegmenter(int32_t transport_stream_timestamp_offset); virtual ~PackedAudioSegmenter(); /// Initialize the object. @@ -81,7 +81,7 @@ class PackedAudioSegmenter { Status EncryptionAudioSetup(const MediaSample& sample); Status StartNewSegment(const MediaSample& first_sample); - const uint32_t transport_stream_timestamp_offset_ = 0; + const int32_t transport_stream_timestamp_offset_ = 0; // Codec for the stream. Codec codec_ = kUnknownCodec; std::vector audio_codec_config_; diff --git a/packager/media/formats/packed_audio/packed_audio_segmenter_unittest.cc b/packager/media/formats/packed_audio/packed_audio_segmenter_unittest.cc index ae03d79ac8..08c6227ccd 100644 --- a/packager/media/formats/packed_audio/packed_audio_segmenter_unittest.cc +++ b/packager/media/formats/packed_audio/packed_audio_segmenter_unittest.cc @@ -28,13 +28,13 @@ namespace shaka { namespace media { namespace { -constexpr uint32_t kZeroTransportStreamTimestampOffset = 0; -constexpr uint32_t kTimescale = 5625; +constexpr int32_t kZeroTransportStreamTimestampOffset = 0; +constexpr int32_t kTimescale = 5625; constexpr double kExpectedTimescaleScale = kPackedAudioTimescale / kTimescale; static_assert(kExpectedTimescaleScale == 16.0, ""); const int kTrackId = 0; -const uint64_t kDuration = 180000; +const int64_t kDuration = 180000; const char kCodecString[] = "codec-string"; const char kLanguage[] = "eng"; const bool kIsEncrypted = true; diff --git a/packager/media/formats/packed_audio/packed_audio_writer.cc b/packager/media/formats/packed_audio/packed_audio_writer.cc index 0b17cf3872..a319fb593a 100644 --- a/packager/media/formats/packed_audio/packed_audio_writer.cc +++ b/packager/media/formats/packed_audio/packed_audio_writer.cc @@ -73,7 +73,7 @@ Status PackedAudioWriter::FinalizeSegment(size_t stream_id, RETURN_IF_ERROR(segmenter_->FinalizeSegment()); - const uint64_t segment_timestamp = + const int64_t segment_timestamp = segment_info.start_timestamp * segmenter_->TimescaleScale(); std::string segment_path = options().segment_template.empty() diff --git a/packager/media/formats/packed_audio/packed_audio_writer.h b/packager/media/formats/packed_audio/packed_audio_writer.h index 816327838b..117c6ee68b 100644 --- a/packager/media/formats/packed_audio/packed_audio_writer.h +++ b/packager/media/formats/packed_audio/packed_audio_writer.h @@ -43,14 +43,14 @@ class PackedAudioWriter : public Muxer { Status CloseFile(std::unique_ptr file); - const uint32_t transport_stream_timestamp_offset_ = 0; + const int32_t transport_stream_timestamp_offset_ = 0; std::unique_ptr segmenter_; // Used in single segment mode. std::unique_ptr output_file_; // Keeps track of segment ranges in single segment mode. MuxerListener::MediaRanges media_ranges_; - uint64_t total_duration_ = 0; + int64_t total_duration_ = 0; // Used in multi-segment mode for segment template. uint64_t segment_number_ = 0; diff --git a/packager/media/formats/packed_audio/packed_audio_writer_unittest.cc b/packager/media/formats/packed_audio/packed_audio_writer_unittest.cc index 18c68fe515..2393b57b44 100644 --- a/packager/media/formats/packed_audio/packed_audio_writer_unittest.cc +++ b/packager/media/formats/packed_audio/packed_audio_writer_unittest.cc @@ -35,8 +35,8 @@ const size_t kOutputs = 0; const size_t kInput = 0; const size_t kStreamIndex = 0; -const uint32_t kZeroTransportStreamTimestampOffset = 0; -const uint32_t kTimescale = 9000; +const int32_t kZeroTransportStreamTimestampOffset = 0; +const int32_t kTimescale = 9000; // For single-segment mode. const char kOutputFile[] = "memory://test.aac"; diff --git a/packager/media/formats/ttml/ttml_generator.cc b/packager/media/formats/ttml/ttml_generator.cc index c0505de646..883691f670 100644 --- a/packager/media/formats/ttml/ttml_generator.cc +++ b/packager/media/formats/ttml/ttml_generator.cc @@ -18,7 +18,7 @@ namespace { constexpr const char* kRegionIdPrefix = "_shaka_region_"; -std::string ToTtmlTime(int64_t time, uint32_t timescale) { +std::string ToTtmlTime(int64_t time, int32_t timescale) { int64_t remaining = time * 1000 / timescale; const int ms = remaining % 1000; @@ -49,7 +49,7 @@ TtmlGenerator::~TtmlGenerator() {} void TtmlGenerator::Initialize(const std::map& regions, const std::string& language, - uint32_t time_scale) { + int32_t time_scale) { regions_ = regions; language_ = language; time_scale_ = time_scale; diff --git a/packager/media/formats/ttml/ttml_generator.h b/packager/media/formats/ttml/ttml_generator.h index c0bc32e2f3..5c6b81335c 100644 --- a/packager/media/formats/ttml/ttml_generator.h +++ b/packager/media/formats/ttml/ttml_generator.h @@ -28,7 +28,7 @@ class TtmlGenerator { void Initialize(const std::map& regions, const std::string& language, - uint32_t time_scale); + int32_t time_scale); void AddSample(const TextSample& sample); void Reset(); @@ -47,7 +47,7 @@ class TtmlGenerator { std::list samples_; std::map regions_; std::string language_; - uint32_t time_scale_; + int32_t time_scale_; // This is modified in "const" methods to create unique IDs. mutable uint32_t region_id_ = 0; }; diff --git a/packager/media/formats/ttml/ttml_generator_unittest.cc b/packager/media/formats/ttml/ttml_generator_unittest.cc index 5997d77719..8ae644c8c8 100644 --- a/packager/media/formats/ttml/ttml_generator_unittest.cc +++ b/packager/media/formats/ttml/ttml_generator_unittest.cc @@ -15,7 +15,7 @@ namespace ttml { namespace { -const uint64_t kMsTimeScale = 1000u; +const int64_t kMsTimeScale = 1000; const TextFragmentStyle kNoStyles{}; const bool kNewline = true; @@ -37,7 +37,7 @@ struct TestProperties { std::map regions; std::string language = ""; - uint32_t time_scale = kMsTimeScale; + int32_t time_scale = kMsTimeScale; }; } // namespace diff --git a/packager/media/formats/webm/encrypted_segmenter_unittest.cc b/packager/media/formats/webm/encrypted_segmenter_unittest.cc index 3054e193f4..663b9261a6 100644 --- a/packager/media/formats/webm/encrypted_segmenter_unittest.cc +++ b/packager/media/formats/webm/encrypted_segmenter_unittest.cc @@ -12,8 +12,8 @@ namespace shaka { namespace media { namespace { -const uint32_t kTimeScale = 1000000u; -const uint64_t kDuration = 1000000u; +const int32_t kTimeScale = 1000000; +const int64_t kDuration = 1000000; const bool kSubsegment = true; const uint8_t kPerSampleIvSize = 8u; const uint8_t kKeyId[] = { diff --git a/packager/media/formats/webm/multi_segment_segmenter.cc b/packager/media/formats/webm/multi_segment_segmenter.cc index 5cd46dddae..8b4ca97cf6 100644 --- a/packager/media/formats/webm/multi_segment_segmenter.cc +++ b/packager/media/formats/webm/multi_segment_segmenter.cc @@ -22,8 +22,8 @@ MultiSegmentSegmenter::MultiSegmentSegmenter(const MuxerOptions& options) MultiSegmentSegmenter::~MultiSegmentSegmenter() {} -Status MultiSegmentSegmenter::FinalizeSegment(uint64_t start_timestamp, - uint64_t duration_timestamp, +Status MultiSegmentSegmenter::FinalizeSegment(int64_t start_timestamp, + int64_t duration_timestamp, bool is_subsegment) { CHECK(cluster()); RETURN_IF_ERROR(Segmenter::FinalizeSegment( @@ -85,7 +85,7 @@ Status MultiSegmentSegmenter::DoFinalize() { return Status::OK; } -Status MultiSegmentSegmenter::NewSegment(uint64_t start_timestamp, +Status MultiSegmentSegmenter::NewSegment(int64_t start_timestamp, bool is_subsegment) { if (!is_subsegment) { temp_file_name_ = @@ -100,7 +100,7 @@ Status MultiSegmentSegmenter::NewSegment(uint64_t start_timestamp, return status; } - const uint64_t start_timecode = FromBmffTimestamp(start_timestamp); + const int64_t start_timecode = FromBmffTimestamp(start_timestamp); return SetCluster(start_timecode, 0, writer_.get()); } diff --git a/packager/media/formats/webm/multi_segment_segmenter.h b/packager/media/formats/webm/multi_segment_segmenter.h index a740994260..bbf2bfcd85 100644 --- a/packager/media/formats/webm/multi_segment_segmenter.h +++ b/packager/media/formats/webm/multi_segment_segmenter.h @@ -29,8 +29,8 @@ class MultiSegmentSegmenter : public Segmenter { /// @name Segmenter implementation overrides. /// @{ - Status FinalizeSegment(uint64_t start_timestamp, - uint64_t duration_timestamp, + Status FinalizeSegment(int64_t start_timestamp, + int64_t duration_timestamp, bool is_subsegment) override; bool GetInitRangeStartAndEnd(uint64_t* start, uint64_t* end) override; bool GetIndexRangeStartAndEnd(uint64_t* start, uint64_t* end) override; @@ -44,7 +44,7 @@ class MultiSegmentSegmenter : public Segmenter { private: // Segmenter implementation overrides. - Status NewSegment(uint64_t start_timestamp, bool is_subsegment) override; + Status NewSegment(int64_t start_timestamp, bool is_subsegment) override; std::unique_ptr writer_; uint32_t num_segment_; diff --git a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc index 5513f00c51..96d0673804 100644 --- a/packager/media/formats/webm/multi_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/multi_segment_segmenter_unittest.cc @@ -13,8 +13,8 @@ namespace shaka { namespace media { namespace { -const uint32_t kTimeScale = 1000000u; -const uint64_t kDuration = 1000000u; +const int32_t kTimeScale = 1000000; +const int64_t kDuration = 1000000; const bool kSubsegment = true; const uint8_t kBasicSupportDataInit[] = { diff --git a/packager/media/formats/webm/segmenter.cc b/packager/media/formats/webm/segmenter.cc index 52e4338124..4db666c8c8 100644 --- a/packager/media/formats/webm/segmenter.cc +++ b/packager/media/formats/webm/segmenter.cc @@ -49,23 +49,23 @@ uint64_t Round(double value) { // uint64_t/int64_t, which is sufficient to represent a time as large as 292 // years. -uint64_t BmffTimestampToNs(uint64_t timestamp, uint64_t time_scale) { +int64_t BmffTimestampToNs(int64_t timestamp, int64_t time_scale) { // Casting to double is needed otherwise kSecondsToNs * timestamp may overflow // uint64_t/int64_t. return Round(static_cast(timestamp) / time_scale * kSecondsToNs); } -uint64_t NsToBmffTimestamp(uint64_t ns, uint64_t time_scale) { +int64_t NsToBmffTimestamp(int64_t ns, int64_t time_scale) { // Casting to double is needed otherwise ns * time_scale may overflow // uint64_t/int64_t. return Round(static_cast(ns) / kSecondsToNs * time_scale); } -uint64_t NsToWebMTimecode(uint64_t ns, uint64_t timecode_scale) { +int64_t NsToWebMTimecode(int64_t ns, int64_t timecode_scale) { return ns / timecode_scale; } -uint64_t WebMTimecodeToNs(uint64_t timecode, uint64_t timecode_scale) { +int64_t WebMTimecodeToNs(int64_t timecode, int64_t timecode_scale) { return timecode * timecode_scale; } @@ -151,7 +151,7 @@ Status Segmenter::Initialize(const StreamInfo& info, Status Segmenter::Finalize() { if (prev_sample_ && !prev_sample_->end_of_stream()) { - uint64_t duration = + int64_t duration = prev_sample_->pts() - first_timestamp_ + prev_sample_->duration(); segment_info_.set_duration(FromBmffTimestamp(duration)); } @@ -194,8 +194,8 @@ Status Segmenter::AddSample(const MediaSample& source_sample) { return Status::OK; } -Status Segmenter::FinalizeSegment(uint64_t start_timestamp, - uint64_t duration_timestamp, +Status Segmenter::FinalizeSegment(int64_t start_timestamp, + int64_t duration_timestamp, bool is_subsegment) { if (is_subsegment) new_subsegment_ = true; @@ -210,13 +210,13 @@ float Segmenter::GetDurationInSeconds() const { static_cast(kSecondsToNs); } -uint64_t Segmenter::FromBmffTimestamp(uint64_t bmff_timestamp) { +int64_t Segmenter::FromBmffTimestamp(int64_t bmff_timestamp) { return NsToWebMTimecode( BmffTimestampToNs(bmff_timestamp, time_scale_), segment_info_.timecode_scale()); } -uint64_t Segmenter::FromWebMTimecode(uint64_t webm_timecode) { +int64_t Segmenter::FromWebMTimecode(int64_t webm_timecode) { return NsToBmffTimestamp( WebMTimecodeToNs(webm_timecode, segment_info_.timecode_scale()), time_scale_); @@ -260,10 +260,10 @@ Status Segmenter::WriteSegmentHeader(uint64_t file_size, MkvWriter* writer) { return Status::OK; } -Status Segmenter::SetCluster(uint64_t start_webm_timecode, +Status Segmenter::SetCluster(int64_t start_webm_timecode, uint64_t position, MkvWriter* writer) { - const uint64_t scale = segment_info_.timecode_scale(); + const int64_t scale = segment_info_.timecode_scale(); cluster_.reset(new mkvmuxer::Cluster(start_webm_timecode, position, scale)); cluster_->Init(writer); return Status::OK; diff --git a/packager/media/formats/webm/segmenter.h b/packager/media/formats/webm/segmenter.h index f6c7c2184d..d3a4362552 100644 --- a/packager/media/formats/webm/segmenter.h +++ b/packager/media/formats/webm/segmenter.h @@ -55,8 +55,8 @@ class Segmenter { Status AddSample(const MediaSample& sample); /// Finalize the (sub)segment. - virtual Status FinalizeSegment(uint64_t start_timestamp, - uint64_t duration_timestamp, + virtual Status FinalizeSegment(int64_t start_timestamp, + int64_t duration_timestamp, bool is_subsegment) = 0; /// @return true if there is an initialization range, while setting @a start @@ -77,13 +77,13 @@ class Segmenter { protected: /// Converts the given time in ISO BMFF timestamp to WebM timecode. - uint64_t FromBmffTimestamp(uint64_t bmff_timestamp); + int64_t FromBmffTimestamp(int64_t bmff_timestamp); /// Converts the given time in WebM timecode to ISO BMFF timestamp. - uint64_t FromWebMTimecode(uint64_t webm_timecode); + int64_t FromWebMTimecode(int64_t webm_timecode); /// Writes the Segment header to @a writer. Status WriteSegmentHeader(uint64_t file_size, MkvWriter* writer); /// Creates a Cluster object with the given parameters. - Status SetCluster(uint64_t start_webm_timecode, + Status SetCluster(int64_t start_webm_timecode, uint64_t position, MkvWriter* writer); @@ -100,7 +100,7 @@ class Segmenter { int track_id() const { return track_id_; } uint64_t segment_payload_pos() const { return segment_payload_pos_; } - uint64_t duration() const { return duration_; } + int64_t duration() const { return duration_; } virtual Status DoInitialize() = 0; virtual Status DoFinalize() = 0; @@ -118,13 +118,13 @@ class Segmenter { // In single-segment mode, a Cluster is a segment and there is no subsegment. // In multi-segment mode, a new file is a segment and the clusters in the file // are subsegments. - virtual Status NewSegment(uint64_t start_timestamp, bool is_subsegment) = 0; + virtual Status NewSegment(int64_t start_timestamp, bool is_subsegment) = 0; // Store the previous sample so we know which one is the last frame. std::shared_ptr prev_sample_; // The reference frame timestamp; used to populate the ReferenceBlock element // when writing non-keyframe BlockGroups. - uint64_t reference_frame_timestamp_ = 0; + int64_t reference_frame_timestamp_ = 0; const MuxerOptions& options_; @@ -138,7 +138,7 @@ class Segmenter { ProgressListener* progress_listener_ = nullptr; uint64_t progress_target_ = 0; uint64_t accumulated_progress_ = 0; - uint64_t first_timestamp_ = 0; + int64_t first_timestamp_ = 0; int64_t sample_duration_ = 0; // The position (in bytes) of the start of the Segment payload in the init // file. This is also the size of the header before the SeekHead. @@ -153,8 +153,8 @@ class Segmenter { // The subset of information that we need from StreamInfo bool is_encrypted_ = false; - uint64_t time_scale_ = 0; - uint64_t duration_ = 0; + int64_t time_scale_ = 0; + int64_t duration_ = 0; DISALLOW_COPY_AND_ASSIGN(Segmenter); }; diff --git a/packager/media/formats/webm/segmenter_test_base.cc b/packager/media/formats/webm/segmenter_test_base.cc index c8a589630a..3cbf74e9da 100644 --- a/packager/media/formats/webm/segmenter_test_base.cc +++ b/packager/media/formats/webm/segmenter_test_base.cc @@ -22,7 +22,7 @@ const uint8_t kTestMediaSampleSideData[] = { 0x73, 0x69, 0x64, 0x65, 0x00}; const int kTrackId = 1; -const uint64_t kDurationInSeconds = 8; +const int64_t kDurationInSeconds = 8; const Codec kCodec = kCodecVP8; const std::string kCodecString = "vp8"; const std::string kLanguage = "en"; @@ -51,7 +51,7 @@ void SegmentTestBase::TearDown() { std::shared_ptr SegmentTestBase::CreateSample( KeyFrameFlag key_frame_flag, - uint64_t duration, + int64_t duration, SideDataFlag side_data_flag) { std::shared_ptr sample; const bool is_key_frame = key_frame_flag == kKeyFrame; @@ -82,7 +82,7 @@ MuxerOptions SegmentTestBase::CreateMuxerOptions() const { } VideoStreamInfo* SegmentTestBase::CreateVideoStreamInfo( - uint32_t time_scale) const { + int32_t time_scale) const { return new VideoStreamInfo( kTrackId, time_scale, kDurationInSeconds * time_scale, kCodec, H26xStreamFormat::kUnSpecified, kCodecString, NULL, 0, kWidth, kHeight, diff --git a/packager/media/formats/webm/segmenter_test_base.h b/packager/media/formats/webm/segmenter_test_base.h index 9e1a6342c7..b5304a54ed 100644 --- a/packager/media/formats/webm/segmenter_test_base.h +++ b/packager/media/formats/webm/segmenter_test_base.h @@ -57,12 +57,12 @@ class SegmentTestBase : public ::testing::Test { /// Creates a new media sample. std::shared_ptr CreateSample(KeyFrameFlag key_frame_flag, - uint64_t duration, + int64_t duration, SideDataFlag side_data_flag); /// Creates a Muxer options object for testing. MuxerOptions CreateMuxerOptions() const; /// Creates a video stream info object for testing. - VideoStreamInfo* CreateVideoStreamInfo(uint32_t time_scale) const; + VideoStreamInfo* CreateVideoStreamInfo(int32_t time_scale) const; /// Gets the file name of the current output file. std::string OutputFileName() const; @@ -103,11 +103,11 @@ class SegmentTestBase : public ::testing::Test { }; protected: - void set_cur_timestamp(uint64_t timestamp) { cur_timestamp_ = timestamp; } + void set_cur_timestamp(int64_t timestamp) { cur_timestamp_ = timestamp; } std::string output_file_name_; std::string segment_template_; - uint64_t cur_timestamp_; + int64_t cur_timestamp_; bool single_segment_; }; diff --git a/packager/media/formats/webm/single_segment_segmenter.cc b/packager/media/formats/webm/single_segment_segmenter.cc index 29a6be7572..997a51df4b 100644 --- a/packager/media/formats/webm/single_segment_segmenter.cc +++ b/packager/media/formats/webm/single_segment_segmenter.cc @@ -19,8 +19,8 @@ SingleSegmentSegmenter::SingleSegmentSegmenter(const MuxerOptions& options) SingleSegmentSegmenter::~SingleSegmentSegmenter() {} -Status SingleSegmentSegmenter::FinalizeSegment(uint64_t start_timestamp, - uint64_t duration_timestamp, +Status SingleSegmentSegmenter::FinalizeSegment(int64_t start_timestamp, + int64_t duration_timestamp, bool is_subsegment) { Status status = Segmenter::FinalizeSegment(start_timestamp, duration_timestamp, is_subsegment); @@ -109,14 +109,14 @@ Status SingleSegmentSegmenter::DoFinalize() { return status; } -Status SingleSegmentSegmenter::NewSegment(uint64_t start_timestamp, +Status SingleSegmentSegmenter::NewSegment(int64_t start_timestamp, bool is_subsegment) { // No-op for subsegment in single segment mode. if (is_subsegment) return Status::OK; // Create a new Cue point. uint64_t position = writer_->Position(); - uint64_t start_timecode = FromBmffTimestamp(start_timestamp); + int64_t start_timecode = FromBmffTimestamp(start_timestamp); mkvmuxer::CuePoint* cue_point = new mkvmuxer::CuePoint; cue_point->set_time(start_timecode); diff --git a/packager/media/formats/webm/single_segment_segmenter.h b/packager/media/formats/webm/single_segment_segmenter.h index 0115fcd0af..0f23b584ba 100644 --- a/packager/media/formats/webm/single_segment_segmenter.h +++ b/packager/media/formats/webm/single_segment_segmenter.h @@ -30,8 +30,8 @@ class SingleSegmentSegmenter : public Segmenter { /// @name Segmenter implementation overrides. /// @{ - Status FinalizeSegment(uint64_t start_timestamp, - uint64_t duration_timestamp, + Status FinalizeSegment(int64_t start_timestamp, + int64_t duration_timestamp, bool is_subsegment) override; bool GetInitRangeStartAndEnd(uint64_t* start, uint64_t* end) override; bool GetIndexRangeStartAndEnd(uint64_t* start, uint64_t* end) override; @@ -54,7 +54,7 @@ class SingleSegmentSegmenter : public Segmenter { private: // Segmenter implementation overrides. - Status NewSegment(uint64_t start_timestamp, bool is_subsegment) override; + Status NewSegment(int64_t start_timestamp, bool is_subsegment) override; std::unique_ptr writer_; uint64_t init_end_; diff --git a/packager/media/formats/webm/single_segment_segmenter_unittest.cc b/packager/media/formats/webm/single_segment_segmenter_unittest.cc index 175931183b..318cc6ccff 100644 --- a/packager/media/formats/webm/single_segment_segmenter_unittest.cc +++ b/packager/media/formats/webm/single_segment_segmenter_unittest.cc @@ -12,10 +12,10 @@ namespace shaka { namespace media { namespace { -const uint32_t kTimeScale = 1000000; -const uint32_t kTimecodeScale = 1000000; +const int32_t kTimeScale = 1000000; +const int32_t kTimecodeScale = 1000000; const int64_t kSecondsToNs = 1000000000L; -const uint64_t kDuration = 1000000; +const int64_t kDuration = 1000000; const bool kSubsegment = true; const uint8_t kBasicSupportData[] = { diff --git a/packager/media/formats/webm/two_pass_single_segment_segmenter.cc b/packager/media/formats/webm/two_pass_single_segment_segmenter.cc index 5d99f41478..f8d55c0ae0 100644 --- a/packager/media/formats/webm/two_pass_single_segment_segmenter.cc +++ b/packager/media/formats/webm/two_pass_single_segment_segmenter.cc @@ -166,8 +166,8 @@ bool TwoPassSingleSegmentSegmenter::CopyFileWithClusterRewrite( return false; // Update the progress; need to convert from WebM timecode to ISO BMFF. - const uint64_t webm_delta_time = next_cue->time() - cue->time(); - const uint64_t delta_time = FromWebMTimecode(webm_delta_time); + const int64_t webm_delta_time = next_cue->time() - cue->time(); + const int64_t delta_time = FromWebMTimecode(webm_delta_time); UpdateProgress(delta_time); } diff --git a/packager/media/formats/webm/webm_audio_client.cc b/packager/media/formats/webm/webm_audio_client.cc index 0917cfca12..6c86cecfca 100644 --- a/packager/media/formats/webm/webm_audio_client.cc +++ b/packager/media/formats/webm/webm_audio_client.cc @@ -8,8 +8,8 @@ #include "packager/media/formats/webm/webm_constants.h" namespace { -// Timestamps are represented in double in WebM. Convert to uint64_t in us. -const uint32_t kWebMTimeScale = 1000000u; +// Timestamps are represented in double in WebM. Convert to int64_t in us. +const int32_t kWebMTimeScale = 1000000; } // namespace namespace shaka { diff --git a/packager/media/formats/webm/webm_cluster_parser_unittest.cc b/packager/media/formats/webm/webm_cluster_parser_unittest.cc index 8f883c00c4..6a45010f7a 100644 --- a/packager/media/formats/webm/webm_cluster_parser_unittest.cc +++ b/packager/media/formats/webm/webm_cluster_parser_unittest.cc @@ -75,8 +75,8 @@ const int kTestAudioFrameDefaultDurationInMs = 13; const int kTestVideoFrameDefaultDurationInMs = 17; // Constants for AudioStreamInfo and VideoStreamInfo. Most are not used. -const uint32_t kTimeScale = 1000000u; -const uint64_t kDuration = 10000000u; +const int32_t kTimeScale = 1000000; +const int64_t kDuration = 10000000; const char kCodecString[] = "codec_string"; const char kLanguage[] = "eng"; const uint8_t kBitsPerSample = 8u; @@ -92,7 +92,7 @@ const uint16_t kHeight = 180u; const uint32_t kPixelWidth = 1u; const uint32_t kPixelHeight = 1u; const uint8_t kTransferCharacteristics = 0; -const int16_t kTrickPlayFactor = 0u; +const int16_t kTrickPlayFactor = 0; const uint8_t kNaluLengthSize = 0u; // Test duration defaults must differ from parser estimation defaults to know diff --git a/packager/media/formats/webm/webm_muxer.cc b/packager/media/formats/webm/webm_muxer.cc index 18e8a51dd0..de2f446bec 100644 --- a/packager/media/formats/webm/webm_muxer.cc +++ b/packager/media/formats/webm/webm_muxer.cc @@ -90,7 +90,7 @@ void WebMMuxer::FireOnMediaStartEvent() { DCHECK(!streams().empty()) << "Media started without a stream."; - const uint32_t timescale = streams().front()->time_scale(); + const int32_t timescale = streams().front()->time_scale(); muxer_listener()->OnMediaStart(options(), *streams().front(), timescale, MuxerListener::kContainerWebM); } diff --git a/packager/media/formats/webm/webm_video_client.cc b/packager/media/formats/webm/webm_video_client.cc index 48486a5a55..f0fdcd1d25 100644 --- a/packager/media/formats/webm/webm_video_client.cc +++ b/packager/media/formats/webm/webm_video_client.cc @@ -12,8 +12,8 @@ namespace { -// Timestamps are represented in double in WebM. Convert to uint64_t in us. -const uint32_t kWebMTimeScale = 1000000u; +// Timestamps are represented in double in WebM. Convert to int64_t in us. +const int32_t kWebMTimeScale = 1000000; } // namespace diff --git a/packager/media/formats/webvtt/webvtt_file_buffer.cc b/packager/media/formats/webvtt/webvtt_file_buffer.cc index 02507c1858..267a5ccd5f 100644 --- a/packager/media/formats/webvtt/webvtt_file_buffer.cc +++ b/packager/media/formats/webvtt/webvtt_file_buffer.cc @@ -17,9 +17,8 @@ const char* kHeader = "WEBVTT\n"; const int kTsTimescale = 90000; } // namespace -WebVttFileBuffer::WebVttFileBuffer( - uint32_t transport_stream_timestamp_offset_ms, - const std::string& style_region_config) +WebVttFileBuffer::WebVttFileBuffer(int32_t transport_stream_timestamp_offset_ms, + const std::string& style_region_config) : transport_stream_timestamp_offset_(transport_stream_timestamp_offset_ms * kTsTimescale / 1000), style_region_config_(style_region_config) { diff --git a/packager/media/formats/webvtt/webvtt_file_buffer.h b/packager/media/formats/webvtt/webvtt_file_buffer.h index 5656ba93d5..3d9b24adc4 100644 --- a/packager/media/formats/webvtt/webvtt_file_buffer.h +++ b/packager/media/formats/webvtt/webvtt_file_buffer.h @@ -20,7 +20,7 @@ class TextSample; // all the formatting requirements for a webvtt file. class WebVttFileBuffer { public: - WebVttFileBuffer(uint32_t transport_stream_timestamp_offset_ms, + WebVttFileBuffer(int32_t transport_stream_timestamp_offset_ms, const std::string& style_region_config); virtual ~WebVttFileBuffer() = default; @@ -36,7 +36,7 @@ class WebVttFileBuffer { WebVttFileBuffer(const WebVttFileBuffer&) = delete; WebVttFileBuffer& operator=(const WebVttFileBuffer&) = delete; - const uint32_t transport_stream_timestamp_offset_ = 0; + const int32_t transport_stream_timestamp_offset_ = 0; const std::string style_region_config_; std::string buffer_; size_t sample_count_ = 0; diff --git a/packager/media/formats/webvtt/webvtt_muxer_unittest.cc b/packager/media/formats/webvtt/webvtt_muxer_unittest.cc index 77dd516c38..e09cac98c1 100644 --- a/packager/media/formats/webvtt/webvtt_muxer_unittest.cc +++ b/packager/media/formats/webvtt/webvtt_muxer_unittest.cc @@ -31,13 +31,13 @@ const size_t kStreamIndex = 0; const bool kEncrypted = true; const char* kNoId = ""; -const uint64_t kMsTimeScale = 1000u; +const int64_t kMsTimeScale = 1000; const char* kSegmentedFileTemplate = "memory://output/template-$Number$.vtt"; const char* kSegmentedFileOutput1 = "memory://output/template-1.vtt"; const char* kSegmentedFileOutput2 = "memory://output/template-2.vtt"; -const uint64_t kSegmentDuration = 10000; +const int64_t kSegmentDuration = 10000; const float kMillisecondsPerSecond = 1000.0f; } // namespace diff --git a/packager/media/formats/webvtt/webvtt_parser.cc b/packager/media/formats/webvtt/webvtt_parser.cc index 117b7eab7c..796af9306a 100644 --- a/packager/media/formats/webvtt/webvtt_parser.cc +++ b/packager/media/formats/webvtt/webvtt_parser.cc @@ -395,8 +395,8 @@ bool WebVttParser::ParseCue(const std::string& id, const std::vector time_and_style = base::SplitString( block[0], " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); - uint64_t start_time = 0; - uint64_t end_time = 0; + int64_t start_time = 0; + int64_t end_time = 0; const bool parsed_time = time_and_style.size() >= 3 && time_and_style[1] == "-->" && diff --git a/packager/media/formats/webvtt/webvtt_parser_unittest.cc b/packager/media/formats/webvtt/webvtt_parser_unittest.cc index ce9612c95d..59ba49534d 100644 --- a/packager/media/formats/webvtt/webvtt_parser_unittest.cc +++ b/packager/media/formats/webvtt/webvtt_parser_unittest.cc @@ -17,7 +17,7 @@ namespace media { namespace { const uint32_t kStreamId = 0; -const uint32_t kTimeScale = 1000; +const int32_t kTimeScale = 1000; const char* kNoId = ""; diff --git a/packager/media/formats/webvtt/webvtt_to_mp4_handler_unittest.cc b/packager/media/formats/webvtt/webvtt_to_mp4_handler_unittest.cc index 98d3de76e3..4c96c87221 100644 --- a/packager/media/formats/webvtt/webvtt_to_mp4_handler_unittest.cc +++ b/packager/media/formats/webvtt/webvtt_to_mp4_handler_unittest.cc @@ -71,7 +71,7 @@ class WebVttToMp4HandlerTest : public MediaHandlerTestBase { } Status DispatchStream() { - const uint64_t kMsTimeScale = 1000u; + const int64_t kMsTimeScale = 1000; auto info = GetTextStreamInfo(kMsTimeScale); return In()->Dispatch( diff --git a/packager/media/formats/webvtt/webvtt_utils.cc b/packager/media/formats/webvtt/webvtt_utils.cc index 3a7af3f6a7..33206d9f84 100644 --- a/packager/media/formats/webvtt/webvtt_utils.cc +++ b/packager/media/formats/webvtt/webvtt_utils.cc @@ -26,7 +26,7 @@ bool GetTotalMilliseconds(uint64_t hours, uint64_t minutes, uint64_t seconds, uint64_t ms, - uint64_t* out) { + int64_t* out) { DCHECK(out); if (minutes > 59 || seconds > 59 || ms > 999) { VLOG(1) << "Hours:" << hours << " Minutes:" << minutes @@ -160,7 +160,7 @@ std::string WriteFragment(const TextFragment& fragment, } // namespace -bool WebVttTimestampToMs(const base::StringPiece& source, uint64_t* out) { +bool WebVttTimestampToMs(const base::StringPiece& source, int64_t* out) { DCHECK(out); if (source.length() < 9) { diff --git a/packager/media/formats/webvtt/webvtt_utils.h b/packager/media/formats/webvtt/webvtt_utils.h index 744f368321..728475d9fa 100644 --- a/packager/media/formats/webvtt/webvtt_utils.h +++ b/packager/media/formats/webvtt/webvtt_utils.h @@ -23,7 +23,7 @@ namespace media { // Parse a timestamp into milliseconds using the two patterns defined by WebVtt: // LONG : ##:##:##.### (long can have 2 or more hour digits) // SHORT : ##:##:### -bool WebVttTimestampToMs(const base::StringPiece& source, uint64_t* out); +bool WebVttTimestampToMs(const base::StringPiece& source, int64_t* out); // Create a long form timestamp encoded as a string. std::string MsToWebVttTimestamp(uint64_t ms); diff --git a/packager/media/formats/webvtt/webvtt_utils_unittest.cc b/packager/media/formats/webvtt/webvtt_utils_unittest.cc index a56d5d08c6..f87b8389a8 100644 --- a/packager/media/formats/webvtt/webvtt_utils_unittest.cc +++ b/packager/media/formats/webvtt/webvtt_utils_unittest.cc @@ -30,83 +30,83 @@ TextFragmentStyle GetBoldStyle() { } // namespace TEST(WebVttTimestampTest, TooShort) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("00.000", &ms)); } TEST(WebVttTimestampTest, RightLengthButMeaningless) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("ABCDEFGHI", &ms)); } TEST(WebVttTimestampTest, ParseHours) { - uint64_t ms; + int64_t ms; EXPECT_TRUE(WebVttTimestampToMs("12:00:00.000", &ms)); - EXPECT_EQ(43200000u, ms); + EXPECT_EQ(43200000, ms); } TEST(WebVttTimestampTest, ParseLongHours) { - uint64_t ms; + int64_t ms; EXPECT_TRUE(WebVttTimestampToMs("120:00:00.000", &ms)); - EXPECT_EQ(432000000u, ms); + EXPECT_EQ(432000000, ms); } TEST(WebVttTimestampTest, ParseMinutes) { - uint64_t ms; + int64_t ms; EXPECT_TRUE(WebVttTimestampToMs("00:12:00.000", &ms)); - EXPECT_EQ(720000u, ms); + EXPECT_EQ(720000, ms); } TEST(WebVttTimestampTest, ParseSeconds) { - uint64_t ms; + int64_t ms; EXPECT_TRUE(WebVttTimestampToMs("00:00:12.000", &ms)); - EXPECT_EQ(12000u, ms); + EXPECT_EQ(12000, ms); } TEST(WebVttTimestampTest, ParseMs) { - uint64_t ms; + int64_t ms; EXPECT_TRUE(WebVttTimestampToMs("00:00:00.123", &ms)); - EXPECT_EQ(123u, ms); + EXPECT_EQ(123, ms); } TEST(WebVttTimestampTest, ParseNoHours) { - uint64_t ms; + int64_t ms; EXPECT_TRUE(WebVttTimestampToMs("12:00.000", &ms)); - EXPECT_EQ(720000u, ms); + EXPECT_EQ(720000, ms); } TEST(WebVttTimestampTest, FailWithShortHours) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("1:00:00.000", &ms)); } TEST(WebVttTimestampTest, FailWithShortMinutes) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("00:1:00.000", &ms)); } TEST(WebVttTimestampTest, FailWithShortSeconds) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("00:1.000", &ms)); } TEST(WebVttTimestampTest, FailWithShortMs) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("00:00.01", &ms)); } TEST(WebVttTimestampTest, FailWithNonDigit) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("00:0A:00.000", &ms)); } TEST(WebVttTimestampTest, FailWithInvalidMinutes) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("00:79:00.000", &ms)); } TEST(WebVttTimestampTest, FailWithInvalidSeconds) { - uint64_t ms; + int64_t ms; EXPECT_FALSE(WebVttTimestampToMs("00:00:79.000", &ms)); } diff --git a/packager/media/formats/wvm/wvm_media_parser.cc b/packager/media/formats/wvm/wvm_media_parser.cc index f027278440..5b9fbbb1be 100644 --- a/packager/media/formats/wvm/wvm_media_parser.cc +++ b/packager/media/formats/wvm/wvm_media_parser.cc @@ -573,10 +573,10 @@ bool WvmMediaParser::ParseIndexEntry() { return false; } - uint64_t track_duration = 0; + int64_t track_duration = 0; uint32_t trick_play_factor = 0; uint32_t sampling_frequency = kDefaultSamplingFrequency; - uint32_t time_scale = kMpeg2ClockRate; + int32_t time_scale = kMpeg2ClockRate; uint16_t video_width = 0; uint16_t video_height = 0; uint32_t pixel_width = 0; diff --git a/packager/media/formats/wvm/wvm_media_parser.h b/packager/media/formats/wvm/wvm_media_parser.h index 74aa639128..0cc37f1f35 100644 --- a/packager/media/formats/wvm/wvm_media_parser.h +++ b/packager/media/formats/wvm/wvm_media_parser.h @@ -234,8 +234,8 @@ class WvmMediaParser : public MediaParser { uint8_t pes_flags_2_; uint8_t prev_pes_flags_1_; size_t pes_header_data_bytes_; - uint64_t timestamp_; - uint64_t pts_; + int64_t timestamp_; + int64_t pts_; uint64_t dts_; uint8_t index_program_id_; std::shared_ptr media_sample_; diff --git a/packager/media/trick_play/trick_play_handler_unittest.cc b/packager/media/trick_play/trick_play_handler_unittest.cc index 7a58746884..c1eb7e464d 100644 --- a/packager/media/trick_play/trick_play_handler_unittest.cc +++ b/packager/media/trick_play/trick_play_handler_unittest.cc @@ -27,7 +27,7 @@ const size_t kStreamIndex = 0; // This value does not matter as trick play does not use it, but it is needed // to create the audio and video info. -const uint32_t kTimescale = 1000u; +const int32_t kTimescale = 1000; const bool kKeyFrame = true; } // namespace diff --git a/packager/mpd/base/adaptation_set.cc b/packager/mpd/base/adaptation_set.cc index e0257940fe..154a9fe588 100644 --- a/packager/mpd/base/adaptation_set.cc +++ b/packager/mpd/base/adaptation_set.cc @@ -148,8 +148,8 @@ class RepresentationStateChangeListenerImpl start_time, duration); } - void OnSetFrameRateForRepresentation(uint32_t frame_duration, - uint32_t timescale) override { + void OnSetFrameRateForRepresentation(int32_t frame_duration, + int32_t timescale) override { adaptation_set_->OnSetFrameRateForRepresentation(representation_id_, frame_duration, timescale); } @@ -391,8 +391,8 @@ void AdaptationSet::AddAdaptationSetSwitching( // muxer so one might run faster than others). To be clear, for dynamic MPD, all // Representations should be added before a segment is added. void AdaptationSet::OnNewSegmentForRepresentation(uint32_t representation_id, - uint64_t start_time, - uint64_t duration) { + int64_t start_time, + int64_t duration) { if (mpd_options_.mpd_type == MpdType::kDynamic) { CheckDynamicSegmentAlignment(representation_id, start_time, duration); } else { @@ -402,8 +402,8 @@ void AdaptationSet::OnNewSegmentForRepresentation(uint32_t representation_id, } void AdaptationSet::OnSetFrameRateForRepresentation(uint32_t representation_id, - uint32_t frame_duration, - uint32_t timescale) { + int32_t frame_duration, + int32_t timescale) { RecordFrameRate(frame_duration, timescale); } @@ -478,14 +478,14 @@ void AdaptationSet::UpdateFromMediaInfo(const MediaInfo& media_info) { // But since this is unlikely to happen in the packager (and to save // computation), this isn't handled at the moment. void AdaptationSet::CheckDynamicSegmentAlignment(uint32_t representation_id, - uint64_t start_time, - uint64_t /* duration */) { + int64_t start_time, + int64_t /* duration */) { if (segments_aligned_ == kSegmentAlignmentFalse || force_set_segment_alignment_) { return; } - std::list& current_representation_start_times = + std::list& current_representation_start_times = representation_segment_start_times_[representation_id]; current_representation_start_times.push_back(start_time); // There's no way to detemine whether the segments are aligned if some @@ -494,10 +494,10 @@ void AdaptationSet::CheckDynamicSegmentAlignment(uint32_t representation_id, return; DCHECK(!current_representation_start_times.empty()); - const uint64_t expected_start_time = + const int64_t expected_start_time = current_representation_start_times.front(); for (const auto& key_value : representation_segment_start_times_) { - const std::list& representation_start_time = key_value.second; + const std::list& representation_start_time = key_value.second; // If there are no entries in a list, then there is no way for the // segment alignment status to change. // Note that it can be empty because entries get deleted below. @@ -518,7 +518,7 @@ void AdaptationSet::CheckDynamicSegmentAlignment(uint32_t representation_id, segments_aligned_ = kSegmentAlignmentTrue; for (auto& key_value : representation_segment_start_times_) { - std::list& representation_start_time = key_value.second; + std::list& representation_start_time = key_value.second; representation_start_time.pop_front(); } } @@ -540,7 +540,7 @@ void AdaptationSet::CheckStaticSegmentAlignment() { // This is not the most efficient implementation to compare the values // because expected_time_line is compared against all other time lines, but // probably the most readable. - const std::list& expected_time_line = + const std::list& expected_time_line = representation_segment_start_times_.begin()->second; bool all_segment_time_line_same_length = true; @@ -548,13 +548,13 @@ void AdaptationSet::CheckStaticSegmentAlignment() { RepresentationTimeline::const_iterator it = representation_segment_start_times_.begin(); for (++it; it != representation_segment_start_times_.end(); ++it) { - const std::list& other_time_line = it->second; + const std::list& other_time_line = it->second; if (expected_time_line.size() != other_time_line.size()) { all_segment_time_line_same_length = false; } - const std::list* longer_list = &other_time_line; - const std::list* shorter_list = &expected_time_line; + const std::list* longer_list = &other_time_line; + const std::list* shorter_list = &expected_time_line; if (expected_time_line.size() > other_time_line.size()) { shorter_list = &other_time_line; longer_list = &expected_time_line; @@ -585,8 +585,7 @@ void AdaptationSet::CheckStaticSegmentAlignment() { // Since all AdaptationSet cares about is the maxFrameRate, representation_id // is not passed to this method. -void AdaptationSet::RecordFrameRate(uint32_t frame_duration, - uint32_t timescale) { +void AdaptationSet::RecordFrameRate(int32_t frame_duration, int32_t timescale) { if (frame_duration == 0) { LOG(ERROR) << "Frame duration is 0 and cannot be set."; return; diff --git a/packager/mpd/base/adaptation_set.h b/packager/mpd/base/adaptation_set.h index dfc299a34a..c288ad857a 100644 --- a/packager/mpd/base/adaptation_set.h +++ b/packager/mpd/base/adaptation_set.h @@ -143,8 +143,8 @@ class AdaptationSet { /// @param start_time is the start time of the new segment. /// @param duration is the duration of the new segment. void OnNewSegmentForRepresentation(uint32_t representation_id, - uint64_t start_time, - uint64_t duration); + int64_t start_time, + int64_t duration); /// Notifies the AdaptationSet instance that the sample duration for the /// Representation was set. @@ -159,8 +159,8 @@ class AdaptationSet { /// @frame_duration is the duration of a frame in the Representation. /// @param timescale is the timescale of the Representation. void OnSetFrameRateForRepresentation(uint32_t representation_id, - uint32_t frame_duration, - uint32_t timescale); + int32_t frame_duration, + int32_t timescale); /// Add the adaptation set this trick play adaptation set belongs to. /// @param adaptation_set points to the reference (or main) adapation set. @@ -216,7 +216,7 @@ class AdaptationSet { // start times 0, 200, 400, then the map contains: // 1 -> [0, 100, 200] // 2 -> [0, 200, 400] - typedef std::map> RepresentationTimeline; + typedef std::map> RepresentationTimeline; // Update AdaptationSet attributes for new MediaInfo. void UpdateFromMediaInfo(const MediaInfo& media_info); @@ -230,15 +230,15 @@ class AdaptationSet { /// @param start_time is the start time of the new segment. /// @param duration is the duration of the new segment. void CheckDynamicSegmentAlignment(uint32_t representation_id, - uint64_t start_time, - uint64_t duration); + int64_t start_time, + int64_t duration); // Checks representation_segment_start_times_ and sets segments_aligned_. // Use this for static MPD, do not use for dynamic MPD. void CheckStaticSegmentAlignment(); // Records the framerate of a Representation. - void RecordFrameRate(uint32_t frame_duration, uint32_t timescale); + void RecordFrameRate(int32_t frame_duration, int32_t timescale); std::list content_protection_elements_; // representation_id => Representation map. It also keeps the representations_ diff --git a/packager/mpd/base/adaptation_set_unittest.cc b/packager/mpd/base/adaptation_set_unittest.cc index 62c9e78526..40f04ac39f 100644 --- a/packager/mpd/base/adaptation_set_unittest.cc +++ b/packager/mpd/base/adaptation_set_unittest.cc @@ -332,7 +332,7 @@ TEST_F(AdaptationSetTest, // Then set same frame duration for the representations. (Given that the // time scales match). - const uint32_t kSameFrameDuration = 3u; + const int32_t kSameFrameDuration = 3; representation_480p->SetSampleDuration(kSameFrameDuration); representation_360p->SetSampleDuration(kSameFrameDuration); @@ -341,7 +341,7 @@ TEST_F(AdaptationSetTest, EXPECT_THAT(same_frame_rate, AttributeEqual("frameRate", "10/3")); // Then set 480p to be 5fps (10/2) so that maxFrameRate is set. - const uint32_t k5FPSFrameDuration = 2; + const int32_t k5FPSFrameDuration = 2; static_assert(k5FPSFrameDuration < kSameFrameDuration, "frame_duration_must_be_shorter_for_max_frame_rate"); representation_480p->SetSampleDuration(k5FPSFrameDuration); @@ -673,8 +673,8 @@ TEST_F(OnDemandAdaptationSetTest, SubsegmentAlignment) { // First use same start time and duration, and verify that subsegmentAlignment // is set to true. - const uint64_t kStartTime = 0u; - const uint64_t kDuration = 10u; + const int64_t kStartTime = 0; + const int64_t kDuration = 10; const uint64_t kAnySize = 19834u; auto adaptation_set = CreateAdaptationSet(kNoLanguage); @@ -735,10 +735,10 @@ TEST_F(OnDemandAdaptationSetTest, ForceSetsubsegmentAlignment) { adaptation_set->AddRepresentation(ConvertToMediaInfo(k360pMediaInfo)); // Use different starting times to make the segments "not aligned". - const uint64_t kStartTime1 = 1u; - const uint64_t kStartTime2 = 2u; + const int64_t kStartTime1 = 1; + const int64_t kStartTime2 = 2; static_assert(kStartTime1 != kStartTime2, "StartTimesShouldBeDifferent"); - const uint64_t kDuration = 10u; + const int64_t kDuration = 10; const uint64_t kAnySize = 19834u; representation_480p->AddNewSegment(kStartTime1, kDuration, kAnySize); representation_360p->AddNewSegment(kStartTime2, kDuration, kAnySize); @@ -754,8 +754,8 @@ TEST_F(OnDemandAdaptationSetTest, ForceSetsubsegmentAlignment) { // Verify that segmentAlignment is set to true if all the Representations // segments' are aligned and the DASH profile is Live and MPD type is dynamic. TEST_F(LiveAdaptationSetTest, SegmentAlignmentDynamicMpd) { - const uint64_t kStartTime = 0u; - const uint64_t kDuration = 10u; + const int64_t kStartTime = 0; + const int64_t kDuration = 10; const uint64_t kAnySize = 19834u; const char k480pMediaInfo[] = @@ -808,8 +808,8 @@ TEST_F(LiveAdaptationSetTest, SegmentAlignmentDynamicMpd) { // Verify that segmentAlignment is set to true if all the Representations // segments' are aligned and the DASH profile is Live and MPD type is static. TEST_F(LiveAdaptationSetTest, SegmentAlignmentStaticMpd) { - const uint64_t kStartTime = 0u; - const uint64_t kDuration = 10u; + const int64_t kStartTime = 0; + const int64_t kDuration = 10; const uint64_t kAnySize = 19834u; const char k480pMediaInfo[] = diff --git a/packager/mpd/base/mock_mpd_builder.h b/packager/mpd/base/mock_mpd_builder.h index 6d46396f30..5a870b04f6 100644 --- a/packager/mpd/base/mock_mpd_builder.h +++ b/packager/mpd/base/mock_mpd_builder.h @@ -77,7 +77,7 @@ class MockRepresentation : public Representation { void(const std::string& drm_uuid, const std::string& pssh)); MOCK_METHOD3(AddNewSegment, void(int64_t start_time, int64_t duration, uint64_t size)); - MOCK_METHOD1(SetSampleDuration, void(uint32_t sample_duration)); + MOCK_METHOD1(SetSampleDuration, void(int32_t sample_duration)); MOCK_CONST_METHOD0(GetMediaInfo, const MediaInfo&()); }; diff --git a/packager/mpd/base/mock_mpd_notifier.h b/packager/mpd/base/mock_mpd_notifier.h index 0726f52092..1a97fc8858 100644 --- a/packager/mpd/base/mock_mpd_notifier.h +++ b/packager/mpd/base/mock_mpd_notifier.h @@ -25,13 +25,13 @@ class MockMpdNotifier : public MpdNotifier { MOCK_METHOD2(NotifyNewContainer, bool(const MediaInfo& media_info, uint32_t* container_id)); MOCK_METHOD2(NotifySampleDuration, - bool(uint32_t container_id, uint32_t sample_duration)); + bool(uint32_t container_id, int32_t sample_duration)); MOCK_METHOD4(NotifyNewSegment, bool(uint32_t container_id, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t size)); - MOCK_METHOD2(NotifyCueEvent, bool(uint32_t container_id, uint64_t timestamp)); + MOCK_METHOD2(NotifyCueEvent, bool(uint32_t container_id, int64_t timestamp)); MOCK_METHOD4(NotifyEncryptionUpdate, bool(uint32_t container_id, const std::string& drm_uuid, diff --git a/packager/mpd/base/mpd_notifier.h b/packager/mpd/base/mpd_notifier.h index 22f3c80b9f..51efb4ae44 100644 --- a/packager/mpd/base/mpd_notifier.h +++ b/packager/mpd/base/mpd_notifier.h @@ -54,7 +54,7 @@ class MpdNotifier { /// @return true on success, false otherwise. This may fail if the container /// specified by @a container_id does not exist. virtual bool NotifySampleDuration(uint32_t container_id, - uint32_t sample_duration) = 0; + int32_t sample_duration) = 0; /// Notifies MpdBuilder that there is a new segment ready. For live, this /// is usually a new segment, for VOD this is usually a subsegment. @@ -67,8 +67,8 @@ class MpdNotifier { /// @param size is the new segment size in bytes. /// @return true on success, false otherwise. virtual bool NotifyNewSegment(uint32_t container_id, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t size) = 0; /// Notifies MpdBuilder that there is a new CueEvent. @@ -76,7 +76,7 @@ class MpdNotifier { /// NotifyNewContainer(). /// @param timestamp is the timestamp of the CueEvent. /// @return true on success, false otherwise. - virtual bool NotifyCueEvent(uint32_t container_id, uint64_t timestamp) = 0; + virtual bool NotifyCueEvent(uint32_t container_id, int64_t timestamp) = 0; /// Notifiers MpdBuilder that there is a new PSSH for the container. /// This may be called whenever the key has to change, e.g. key rotation. diff --git a/packager/mpd/base/representation.cc b/packager/mpd/base/representation.cc index 0616540530..a6db341271 100644 --- a/packager/mpd/base/representation.cc +++ b/packager/mpd/base/representation.cc @@ -63,7 +63,7 @@ bool HasRequiredVideoFields(const MediaInfo_VideoInfo& video_info) { return true; } -uint32_t GetTimeScale(const MediaInfo& media_info) { +int32_t GetTimeScale(const MediaInfo& media_info) { if (media_info.has_reference_time_scale()) { return media_info.reference_time_scale(); } @@ -193,7 +193,7 @@ void Representation::AddNewSegment(int64_t start_time, size, static_cast(duration) / media_info_.reference_time_scale()); } -void Representation::SetSampleDuration(uint32_t frame_duration) { +void Representation::SetSampleDuration(int32_t frame_duration) { // Sample duration is used to generate approximate SegmentTimeline. // Text is required to have exactly the same segment duration. if (media_info_.has_audio_info() || media_info_.has_video_info()) @@ -399,10 +399,10 @@ bool Representation::ApproximiatelyEqual(int64_t time1, int64_t time2) const { const double kErrorThresholdSeconds = 0.05; // So we consider two times equal if they differ by less than one sample. - const uint32_t error_threshold = + const int32_t error_threshold = std::min(frame_duration_, - static_cast(kErrorThresholdSeconds * - media_info_.reference_time_scale())); + static_cast(kErrorThresholdSeconds * + media_info_.reference_time_scale())); return std::abs(time1 - time2) <= error_threshold; } @@ -422,8 +422,8 @@ void Representation::SlideWindow() { mpd_options_.mpd_type == MpdType::kStatic) return; - const uint32_t time_scale = GetTimeScale(media_info_); - DCHECK_GT(time_scale, 0u); + const int32_t time_scale = GetTimeScale(media_info_); + DCHECK_GT(time_scale, 0); const int64_t time_shift_buffer_depth = static_cast( mpd_options_.mpd_params.time_shift_buffer_depth * time_scale); diff --git a/packager/mpd/base/representation.h b/packager/mpd/base/representation.h index 942612845e..7c50e51c82 100644 --- a/packager/mpd/base/representation.h +++ b/packager/mpd/base/representation.h @@ -41,8 +41,8 @@ class RepresentationStateChangeListener { /// Representation. /// @param frame_duration is the duration of a frame. /// @param timescale is the timescale of the Representation. - virtual void OnSetFrameRateForRepresentation(uint32_t frame_duration, - uint32_t timescale) = 0; + virtual void OnSetFrameRateForRepresentation(int32_t frame_duration, + int32_t timescale) = 0; }; /// Representation class contains references to a single media stream, as @@ -106,7 +106,7 @@ class Representation { /// allows setting the sample duration after the Representation has been /// initialized. /// @param sample_duration is the duration of a sample. - virtual void SetSampleDuration(uint32_t sample_duration); + virtual void SetSampleDuration(int32_t sample_duration); /// @return MediaInfo for the Representation. virtual const MediaInfo& GetMediaInfo() const; @@ -239,7 +239,7 @@ class Representation { const bool allow_approximate_segment_timeline_ = false; // Segments with duration difference less than one frame duration are // considered to have the same duration. - uint32_t frame_duration_ = 0; + int32_t frame_duration_ = 0; }; } // namespace shaka diff --git a/packager/mpd/base/representation_unittest.cc b/packager/mpd/base/representation_unittest.cc index 832f931e22..76cc73a5ab 100644 --- a/packager/mpd/base/representation_unittest.cc +++ b/packager/mpd/base/representation_unittest.cc @@ -40,7 +40,7 @@ class MockRepresentationStateChangeListener void(int64_t start_time, int64_t duration)); MOCK_METHOD2(OnSetFrameRateForRepresentation, - void(uint32_t frame_duration, uint32_t timescale)); + void(int32_t frame_duration, int32_t timescale)); }; } // namespace @@ -270,8 +270,8 @@ TEST_F(RepresentationTest, "}\n" "container_type: 1\n"; - const int64_t kStartTime = 199238u; - const int64_t kDuration = 98u; + const int64_t kStartTime = 199238; + const int64_t kDuration = 98; std::unique_ptr listener( new MockRepresentationStateChangeListener()); EXPECT_CALL(*listener, OnNewSegmentForRepresentation(kStartTime, kDuration)); @@ -300,8 +300,8 @@ TEST_F(RepresentationTest, "}\n" "container_type: 1\n"; - const uint32_t kTimeScale = 1000u; - const int64_t kFrameDuration = 33u; + const int32_t kTimeScale = 1000; + const int64_t kFrameDuration = 33; std::unique_ptr listener( new MockRepresentationStateChangeListener()); EXPECT_CALL(*listener, @@ -413,11 +413,11 @@ const char kSElementTemplate[] = const char kSElementTemplateWithoutR[] = "\n"; const int kDefaultStartNumber = 1; -const uint32_t kDefaultTimeScale = 1000u; +const int32_t kDefaultTimeScale = 1000; const int64_t kScaledTargetSegmentDuration = 10; const double kTargetSegmentDurationInSeconds = static_cast(kScaledTargetSegmentDuration) / kDefaultTimeScale; -const uint32_t kSampleDuration = 2; +const int32_t kSampleDuration = 2; std::string GetDefaultMediaInfo() { const char kMediaInfo[] = diff --git a/packager/mpd/base/simple_mpd_notifier.cc b/packager/mpd/base/simple_mpd_notifier.cc index 9f93a4a642..7fb74a3278 100644 --- a/packager/mpd/base/simple_mpd_notifier.cc +++ b/packager/mpd/base/simple_mpd_notifier.cc @@ -72,7 +72,7 @@ bool SimpleMpdNotifier::NotifyNewContainer(const MediaInfo& media_info, } bool SimpleMpdNotifier::NotifySampleDuration(uint32_t container_id, - uint32_t sample_duration) { + int32_t sample_duration) { base::AutoLock auto_lock(lock_); auto it = representation_map_.find(container_id); if (it == representation_map_.end()) { @@ -84,8 +84,8 @@ bool SimpleMpdNotifier::NotifySampleDuration(uint32_t container_id, } bool SimpleMpdNotifier::NotifyNewSegment(uint32_t container_id, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t size) { base::AutoLock auto_lock(lock_); auto it = representation_map_.find(container_id); @@ -98,7 +98,7 @@ bool SimpleMpdNotifier::NotifyNewSegment(uint32_t container_id, } bool SimpleMpdNotifier::NotifyCueEvent(uint32_t container_id, - uint64_t timestamp) { + int64_t timestamp) { base::AutoLock auto_lock(lock_); auto it = representation_map_.find(container_id); if (it == representation_map_.end()) { diff --git a/packager/mpd/base/simple_mpd_notifier.h b/packager/mpd/base/simple_mpd_notifier.h index 749da46a1c..79b22f6a08 100644 --- a/packager/mpd/base/simple_mpd_notifier.h +++ b/packager/mpd/base/simple_mpd_notifier.h @@ -37,12 +37,12 @@ class SimpleMpdNotifier : public MpdNotifier { bool Init() override; bool NotifyNewContainer(const MediaInfo& media_info, uint32_t* id) override; bool NotifySampleDuration(uint32_t container_id, - uint32_t sample_duration) override; + int32_t sample_duration) override; bool NotifyNewSegment(uint32_t container_id, - uint64_t start_time, - uint64_t duration, + int64_t start_time, + int64_t duration, uint64_t size) override; - bool NotifyCueEvent(uint32_t container_id, uint64_t timestamp) override; + bool NotifyCueEvent(uint32_t container_id, int64_t timestamp) override; bool NotifyEncryptionUpdate(uint32_t container_id, const std::string& drm_uuid, const std::vector& new_key_id, diff --git a/packager/mpd/base/simple_mpd_notifier_unittest.cc b/packager/mpd/base/simple_mpd_notifier_unittest.cc index f9d3492867..44b12f5568 100644 --- a/packager/mpd/base/simple_mpd_notifier_unittest.cc +++ b/packager/mpd/base/simple_mpd_notifier_unittest.cc @@ -28,7 +28,7 @@ using ::testing::StrEq; namespace { const uint32_t kDefaultPeriodId = 0u; const double kDefaultPeriodStartTime = 0.0; -const uint32_t kDefaultTimeScale = 10; +const int32_t kDefaultTimeScale = 10; const bool kContentProtectionInAdaptationSet = true; MATCHER_P(EqualsProto, message, "") { @@ -145,7 +145,7 @@ TEST_F(SimpleMpdNotifierTest, NotifySampleDuration) { EXPECT_TRUE(notifier.NotifyNewContainer(valid_media_info1_, &container_id)); EXPECT_EQ(kRepresentationId, container_id); - const uint32_t kSampleDuration = 100; + const int32_t kSampleDuration = 100; EXPECT_CALL(*mock_representation, SetSampleDuration(kSampleDuration)); EXPECT_TRUE( notifier.NotifySampleDuration(kRepresentationId, kSampleDuration)); @@ -160,7 +160,7 @@ TEST_F(SimpleMpdNotifierTest, NotifyNewContainerAndSampleDurationNoMock) { SimpleMpdNotifier notifier(empty_mpd_option_); uint32_t container_id; EXPECT_TRUE(notifier.NotifyNewContainer(valid_media_info1_, &container_id)); - const uint32_t kAnySampleDuration = 1000; + const int32_t kAnySampleDuration = 1000; EXPECT_TRUE(notifier.NotifySampleDuration(container_id, kAnySampleDuration)); EXPECT_TRUE(notifier.Flush()); } @@ -185,8 +185,8 @@ TEST_F(SimpleMpdNotifierTest, NotifyNewSegment) { EXPECT_TRUE(notifier.NotifyNewContainer(valid_media_info1_, &container_id)); EXPECT_EQ(kRepresentationId, container_id); - const uint64_t kStartTime = 0u; - const uint32_t kSegmentDuration = 100u; + const int64_t kStartTime = 0; + const int32_t kSegmentDuration = 100; const uint64_t kSegmentSize = 123456u; EXPECT_CALL(*mock_representation, AddNewSegment(kStartTime, kSegmentDuration, kSegmentSize)); @@ -231,7 +231,7 @@ TEST_F(SimpleMpdNotifierTest, NotifyCueEvent) { std::unique_ptr mock_representation2( new MockRepresentation(kRepresentationId)); - const uint64_t kCueEventTimestamp = 1000; + const int64_t kCueEventTimestamp = 1000; EXPECT_CALL(*mock_representation, GetMediaInfo()) .WillOnce(ReturnRef(valid_media_info1_)); EXPECT_CALL(*mock_mpd_builder_ptr, diff --git a/packager/mpd/base/xml/xml_node.cc b/packager/mpd/base/xml/xml_node.cc index c8ebb1a74b..0fb5779902 100644 --- a/packager/mpd/base/xml/xml_node.cc +++ b/packager/mpd/base/xml/xml_node.cc @@ -416,7 +416,7 @@ bool RepresentationXmlNode::AddVODOnlyInfo(const MediaInfo& media_info, media_info.reference_time_scale())); if (use_segment_list && !use_single_segment_url_with_media) { - const uint64_t duration_seconds = static_cast( + const int64_t duration_seconds = static_cast( floor(target_segment_duration * media_info.reference_time_scale())); RCHECK(child.SetIntegerAttribute("duration", duration_seconds)); } diff --git a/packager/mpd/base/xml/xml_node_unittest.cc b/packager/mpd/base/xml/xml_node_unittest.cc index b323ec5434..ad94bea0c3 100644 --- a/packager/mpd/base/xml/xml_node_unittest.cc +++ b/packager/mpd/base/xml/xml_node_unittest.cc @@ -365,8 +365,8 @@ class LiveSegmentTimelineTest : public ::testing::Test { TEST_F(LiveSegmentTimelineTest, OneSegmentInfo) { const uint32_t kStartNumber = 1; - const uint64_t kStartTime = 0; - const uint64_t kDuration = 100; + const int64_t kStartTime = 0; + const int64_t kDuration = 100; const uint64_t kRepeat = 9; std::list segment_infos = { @@ -386,8 +386,8 @@ TEST_F(LiveSegmentTimelineTest, OneSegmentInfo) { TEST_F(LiveSegmentTimelineTest, OneSegmentInfoNonZeroStartTime) { const uint32_t kStartNumber = 1; - const uint64_t kNonZeroStartTime = 500; - const uint64_t kDuration = 100; + const int64_t kNonZeroStartTime = 500; + const int64_t kDuration = 100; const uint64_t kRepeat = 9; std::list segment_infos = { @@ -410,8 +410,8 @@ TEST_F(LiveSegmentTimelineTest, OneSegmentInfoNonZeroStartTime) { TEST_F(LiveSegmentTimelineTest, OneSegmentInfoMatchingStartTimeAndNumber) { const uint32_t kStartNumber = 6; - const uint64_t kNonZeroStartTime = 500; - const uint64_t kDuration = 100; + const int64_t kNonZeroStartTime = 500; + const int64_t kDuration = 100; const uint64_t kRepeat = 9; std::list segment_infos = { @@ -432,12 +432,12 @@ TEST_F(LiveSegmentTimelineTest, OneSegmentInfoMatchingStartTimeAndNumber) { TEST_F(LiveSegmentTimelineTest, AllSegmentsSameDurationExpectLastOne) { const uint32_t kStartNumber = 1; - const uint64_t kStartTime1 = 0; - const uint64_t kDuration1 = 100; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 100; const uint64_t kRepeat1 = 9; - const uint64_t kStartTime2 = kStartTime1 + (kRepeat1 + 1) * kDuration1; - const uint64_t kDuration2 = 200; + const int64_t kStartTime2 = kStartTime1 + (kRepeat1 + 1) * kDuration1; + const int64_t kDuration2 = 200; const uint64_t kRepeat2 = 0; std::list segment_infos = { @@ -459,12 +459,12 @@ TEST_F(LiveSegmentTimelineTest, AllSegmentsSameDurationExpectLastOne) { TEST_F(LiveSegmentTimelineTest, SecondSegmentInfoNonZeroRepeat) { const uint32_t kStartNumber = 1; - const uint64_t kStartTime1 = 0; - const uint64_t kDuration1 = 100; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 100; const uint64_t kRepeat1 = 9; - const uint64_t kStartTime2 = kStartTime1 + (kRepeat1 + 1) * kDuration1; - const uint64_t kDuration2 = 200; + const int64_t kStartTime2 = kStartTime1 + (kRepeat1 + 1) * kDuration1; + const int64_t kDuration2 = 200; const uint64_t kRepeat2 = 1; std::list segment_infos = { @@ -490,13 +490,13 @@ TEST_F(LiveSegmentTimelineTest, SecondSegmentInfoNonZeroRepeat) { TEST_F(LiveSegmentTimelineTest, TwoSegmentInfoWithGap) { const uint32_t kStartNumber = 1; - const uint64_t kStartTime1 = 0; - const uint64_t kDuration1 = 100; + const int64_t kStartTime1 = 0; + const int64_t kDuration1 = 100; const uint64_t kRepeat1 = 9; const uint64_t kGap = 100; - const uint64_t kStartTime2 = kGap + kStartTime1 + (kRepeat1 + 1) * kDuration1; - const uint64_t kDuration2 = 200; + const int64_t kStartTime2 = kGap + kStartTime1 + (kRepeat1 + 1) * kDuration1; + const int64_t kDuration2 = 200; const uint64_t kRepeat2 = 0; std::list segment_infos = { @@ -521,8 +521,8 @@ TEST_F(LiveSegmentTimelineTest, TwoSegmentInfoWithGap) { TEST_F(LiveSegmentTimelineTest, LastSegmentNumberSupplementalProperty) { const uint32_t kStartNumber = 1; - const uint64_t kStartTime = 0; - const uint64_t kDuration = 100; + const int64_t kStartTime = 0; + const int64_t kDuration = 100; const uint64_t kRepeat = 9; std::list segment_infos = { diff --git a/packager/packager.h b/packager/packager.h index d5ad9cc402..38494853ef 100644 --- a/packager/packager.h +++ b/packager/packager.h @@ -43,7 +43,7 @@ struct PackagingParams { /// The offset to be applied to transport stream (e.g. MPEG2-TS, HLS packed /// audio) timestamps to compensate for possible negative timestamps in the /// input. - uint32_t transport_stream_timestamp_offset_ms = 0; + int32_t transport_stream_timestamp_offset_ms = 0; /// Chunking (segmentation) related parameters. ChunkingParams chunking_params;