diff options
author | avi <avi@chromium.org> | 2015-12-08 16:44:49 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-09 00:45:45 +0000 |
commit | dd4e61435aa91c89b1efc083c905f4376ef70aa9 (patch) | |
tree | 14fc41a1e7601470359bfcc3d213c12ebaf15bb8 /media | |
parent | 24f1ae8c7c39f5bd7e03310b91c26b4ce1f93a3f (diff) | |
download | chromium_src-dd4e61435aa91c89b1efc083c905f4376ef70aa9.zip chromium_src-dd4e61435aa91c89b1efc083c905f4376ef70aa9.tar.gz chromium_src-dd4e61435aa91c89b1efc083c905f4376ef70aa9.tar.bz2 |
Remove kint64max.
BUG=138542,488550
Review URL: https://codereview.chromium.org/1498003003
Cr-Commit-Position: refs/heads/master@{#363854}
Diffstat (limited to 'media')
-rw-r--r-- | media/blink/websourcebuffer_impl.cc | 5 | ||||
-rw-r--r-- | media/blink/websourcebuffer_impl.h | 2 | ||||
-rw-r--r-- | media/cast/sender/frame_sender.cc | 37 | ||||
-rw-r--r-- | media/cast/sender/frame_sender.h | 18 | ||||
-rw-r--r-- | media/filters/chunk_demuxer.cc | 9 | ||||
-rw-r--r-- | media/filters/chunk_demuxer.h | 6 | ||||
-rw-r--r-- | media/formats/webm/webm_parser.cc | 90 | ||||
-rw-r--r-- | media/formats/webm/webm_parser.h | 28 | ||||
-rw-r--r-- | media/formats/webm/webm_parser_unittest.cc | 158 |
9 files changed, 192 insertions, 161 deletions
diff --git a/media/blink/websourcebuffer_impl.cc b/media/blink/websourcebuffer_impl.cc index 7e880dd..ffb62c5 100644 --- a/media/blink/websourcebuffer_impl.cc +++ b/media/blink/websourcebuffer_impl.cc @@ -4,6 +4,8 @@ #include "media/blink/websourcebuffer_impl.h" +#include <stdint.h> + #include <cmath> #include <limits> @@ -25,7 +27,8 @@ static base::TimeDelta DoubleToTimeDelta(double time) { // Don't use base::TimeDelta::Max() here, as we want the largest finite time // delta. - base::TimeDelta max_time = base::TimeDelta::FromInternalValue(kint64max - 1); + base::TimeDelta max_time = base::TimeDelta::FromInternalValue( + std::numeric_limits<int64_t>::max() - 1); double max_time_in_seconds = max_time.InSecondsF(); if (time >= max_time_in_seconds) diff --git a/media/blink/websourcebuffer_impl.h b/media/blink/websourcebuffer_impl.h index b03ea7b..600ab70 100644 --- a/media/blink/websourcebuffer_impl.h +++ b/media/blink/websourcebuffer_impl.h @@ -7,8 +7,8 @@ #include <string> -#include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "base/time/time.h" #include "third_party/WebKit/public/platform/WebSourceBuffer.h" diff --git a/media/cast/sender/frame_sender.cc b/media/cast/sender/frame_sender.cc index 44f505e..1df62fb 100644 --- a/media/cast/sender/frame_sender.cc +++ b/media/cast/sender/frame_sender.cc @@ -4,6 +4,8 @@ #include "media/cast/sender/frame_sender.h" +#include <limits> + #include "base/trace_event/trace_event.h" #include "media/cast/cast_defines.h" #include "media/cast/constants.h" @@ -29,7 +31,7 @@ FrameSender::FrameSender(scoped_refptr<CastEnvironment> cast_environment, bool is_audio, CastTransportSender* const transport_sender, int rtp_timebase, - uint32 ssrc, + uint32_t ssrc, double max_frame_rate, base::TimeDelta min_playout_delay, base::TimeDelta max_playout_delay, @@ -37,8 +39,9 @@ FrameSender::FrameSender(scoped_refptr<CastEnvironment> cast_environment, : cast_environment_(cast_environment), transport_sender_(transport_sender), ssrc_(ssrc), - min_playout_delay_(min_playout_delay == base::TimeDelta() ? - max_playout_delay : min_playout_delay), + min_playout_delay_(min_playout_delay == base::TimeDelta() + ? max_playout_delay + : min_playout_delay), max_playout_delay_(max_playout_delay), send_target_playout_delay_(false), max_frame_rate_(max_frame_rate), @@ -86,10 +89,10 @@ void FrameSender::SendRtcpReport(bool schedule_future_reports) { const base::TimeTicks now = cast_environment_->Clock()->NowTicks(); const base::TimeDelta time_delta = now - GetRecordedReferenceTime(last_sent_frame_id_); - const int64 rtp_delta = TimeDeltaToRtpDelta(time_delta, rtp_timebase_); - const uint32 now_as_rtp_timestamp = + const int64_t rtp_delta = TimeDeltaToRtpDelta(time_delta, rtp_timebase_); + const uint32_t now_as_rtp_timestamp = GetRecordedRtpTimestamp(last_sent_frame_id_) + - static_cast<uint32>(rtp_delta); + static_cast<uint32_t>(rtp_delta); transport_sender_->SendSenderReport(ssrc_, now, now_as_rtp_timestamp); if (schedule_future_reports) @@ -160,7 +163,7 @@ void FrameSender::ResendForKickstart() { transport_sender_->ResendFrameForKickstart(ssrc_, last_sent_frame_id_); } -void FrameSender::RecordLatestFrameTimestamps(uint32 frame_id, +void FrameSender::RecordLatestFrameTimestamps(uint32_t frame_id, base::TimeTicks reference_time, RtpTimestamp rtp_timestamp) { DCHECK(!reference_time.is_null()); @@ -170,17 +173,17 @@ void FrameSender::RecordLatestFrameTimestamps(uint32 frame_id, rtp_timestamp; } -base::TimeTicks FrameSender::GetRecordedReferenceTime(uint32 frame_id) const { +base::TimeTicks FrameSender::GetRecordedReferenceTime(uint32_t frame_id) const { return frame_reference_times_[frame_id % arraysize(frame_reference_times_)]; } -RtpTimestamp FrameSender::GetRecordedRtpTimestamp(uint32 frame_id) const { +RtpTimestamp FrameSender::GetRecordedRtpTimestamp(uint32_t frame_id) const { return frame_rtp_timestamps_[frame_id % arraysize(frame_rtp_timestamps_)]; } int FrameSender::GetUnacknowledgedFrameCount() const { const int count = - static_cast<int32>(last_sent_frame_id_ - latest_acked_frame_id_); + static_cast<int32_t>(last_sent_frame_id_ - latest_acked_frame_id_); DCHECK_GE(count, 0); return count; } @@ -201,7 +204,7 @@ void FrameSender::SendEncodedFrame( VLOG(2) << SENDER_SSRC << "About to send another frame: last_sent=" << last_sent_frame_id_ << ", latest_acked=" << latest_acked_frame_id_; - const uint32 frame_id = encoded_frame->frame_id; + const uint32_t frame_id = encoded_frame->frame_id; const bool is_first_frame_to_be_sent = last_send_time_.is_null(); last_send_time_ = cast_environment_->Clock()->NowTicks(); @@ -335,8 +338,8 @@ void FrameSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); const bool is_acked_out_of_order = - static_cast<int32>(cast_feedback.ack_frame_id - - latest_acked_frame_id_) < 0; + static_cast<int32_t>(cast_feedback.ack_frame_id - + latest_acked_frame_id_) < 0; VLOG(2) << SENDER_SSRC << "Received ACK" << (is_acked_out_of_order ? " out-of-order" : "") << " for frame " << cast_feedback.ack_frame_id; @@ -347,7 +350,7 @@ void FrameSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { "latest_acked_frame_id", latest_acked_frame_id_); } else { // Cancel resends of acked frames. - std::vector<uint32> cancel_sending_frames; + std::vector<uint32_t> cancel_sending_frames; while (latest_acked_frame_id_ != cast_feedback.ack_frame_id) { latest_acked_frame_id_++; cancel_sending_frames.push_back(latest_acked_frame_id_); @@ -390,8 +393,10 @@ bool FrameSender::ShouldDropNextFrame(base::TimeDelta frame_duration) const { duration_in_flight + frame_duration; const base::TimeDelta allowed_in_flight = GetAllowedInFlightMediaDuration(); if (VLOG_IS_ON(1)) { - const int64 percent = allowed_in_flight > base::TimeDelta() ? - 100 * duration_would_be_in_flight / allowed_in_flight : kint64max; + const int64_t percent = + allowed_in_flight > base::TimeDelta() + ? 100 * duration_would_be_in_flight / allowed_in_flight + : std::numeric_limits<int64_t>::max(); VLOG_IF(1, percent > 50) << SENDER_SSRC << duration_in_flight.InMicroseconds() << " usec in-flight + " diff --git a/media/cast/sender/frame_sender.h b/media/cast/sender/frame_sender.h index d3b925e..5d606ce 100644 --- a/media/cast/sender/frame_sender.h +++ b/media/cast/sender/frame_sender.h @@ -9,7 +9,9 @@ #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" @@ -28,7 +30,7 @@ class FrameSender { bool is_audio, CastTransportSender* const transport_sender, int rtp_timebase, - uint32 ssrc, + uint32_t ssrc, double max_frame_rate, base::TimeDelta min_playout_delay, base::TimeDelta max_playout_delay, @@ -73,7 +75,7 @@ class FrameSender { // network layer. CastTransportSender* const transport_sender_; - const uint32 ssrc_; + const uint32_t ssrc_; protected: // Schedule and execute periodic checks for re-sending packets. If no @@ -96,11 +98,11 @@ class FrameSender { // Warning: If a frame ID too far in the past is requested, the getters will // silently succeed but return incorrect values. Be sure to respect // media::cast::kMaxUnackedFrames. - void RecordLatestFrameTimestamps(uint32 frame_id, + void RecordLatestFrameTimestamps(uint32_t frame_id, base::TimeTicks reference_time, RtpTimestamp rtp_timestamp); - base::TimeTicks GetRecordedReferenceTime(uint32 frame_id) const; - RtpTimestamp GetRecordedRtpTimestamp(uint32 frame_id) const; + base::TimeTicks GetRecordedReferenceTime(uint32_t frame_id) const; + RtpTimestamp GetRecordedRtpTimestamp(uint32_t frame_id) const; // Returns the number of frames that were sent but not yet acknowledged. int GetUnacknowledgedFrameCount() const; @@ -133,12 +135,12 @@ class FrameSender { // The ID of the last frame sent. Logic throughout FrameSender assumes this // can safely wrap-around. This member is invalid until // |!last_send_time_.is_null()|. - uint32 last_sent_frame_id_; + uint32_t last_sent_frame_id_; // The ID of the latest (not necessarily the last) frame that has been // acknowledged. Logic throughout AudioSender assumes this can safely // wrap-around. This member is invalid until |!last_send_time_.is_null()|. - uint32 latest_acked_frame_id_; + uint32_t latest_acked_frame_id_; // Counts the number of duplicate ACK that are being received. When this // number reaches a threshold, the sender will take this as a sign that the diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc index 869edfb..b96b039 100644 --- a/media/filters/chunk_demuxer.cc +++ b/media/filters/chunk_demuxer.cc @@ -118,7 +118,7 @@ class SourceState { // spec's similarly named source buffer attributes that are used in coded // frame processing. |init_segment_received_cb| is run for each new fully // parsed initialization segment. - bool Append(const uint8* data, + bool Append(const uint8_t* data, size_t length, TimeDelta append_window_start, TimeDelta append_window_end, @@ -325,7 +325,7 @@ void SourceState::SetGroupStartTimestampIfInSequenceMode( } bool SourceState::Append( - const uint8* data, + const uint8_t* data, size_t length, TimeDelta append_window_start, TimeDelta append_window_end, @@ -1453,7 +1453,7 @@ bool ChunkDemuxer::EvictCodedFrames(const std::string& id, void ChunkDemuxer::AppendData( const std::string& id, - const uint8* data, + const uint8_t* data, size_t length, TimeDelta append_window_start, TimeDelta append_window_end, @@ -1594,7 +1594,8 @@ void ChunkDemuxer::SetDuration(double duration) { // precision of TimeDelta. TimeDelta min_duration = TimeDelta::FromInternalValue(1); // Don't use TimeDelta::Max() here, as we want the largest finite time delta. - TimeDelta max_duration = TimeDelta::FromInternalValue(kint64max - 1); + TimeDelta max_duration = + TimeDelta::FromInternalValue(std::numeric_limits<int64_t>::max() - 1); double min_duration_in_seconds = min_duration.InSecondsF(); double max_duration_in_seconds = max_duration.InSecondsF(); diff --git a/media/filters/chunk_demuxer.h b/media/filters/chunk_demuxer.h index db5a2ef..b5d416b 100644 --- a/media/filters/chunk_demuxer.h +++ b/media/filters/chunk_demuxer.h @@ -11,7 +11,7 @@ #include <utility> #include <vector> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/synchronization/lock.h" #include "media/base/byte_queue.h" #include "media/base/demuxer.h" @@ -234,7 +234,9 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer { // processing. // |init_segment_received_cb| is run for each newly successfully parsed // initialization segment. - void AppendData(const std::string& id, const uint8* data, size_t length, + void AppendData(const std::string& id, + const uint8_t* data, + size_t length, base::TimeDelta append_window_start, base::TimeDelta append_window_end, base::TimeDelta* timestamp_offset, diff --git a/media/formats/webm/webm_parser.cc b/media/formats/webm/webm_parser.cc index fda287c..6929a83 100644 --- a/media/formats/webm/webm_parser.cc +++ b/media/formats/webm/webm_parser.cc @@ -12,6 +12,7 @@ // http://wiki.webmproject.org/encryption/webm-encryption-rfc #include <iomanip> +#include <limits> #include "base/logging.h" #include "base/numerics/safe_conversions.h" @@ -423,9 +424,11 @@ static const ListElementInfo kListElementInfo[] = { // element size fields and is false for ID field values. // // Returns: The number of bytes parsed on success. -1 on error. -static int ParseWebMElementHeaderField(const uint8* buf, int size, - int max_bytes, bool mask_first_byte, - int64* num) { +static int ParseWebMElementHeaderField(const uint8_t* buf, + int size, + int max_bytes, + bool mask_first_byte, + int64_t* num) { DCHECK(buf); DCHECK(num); @@ -436,7 +439,7 @@ static int ParseWebMElementHeaderField(const uint8* buf, int size, return 0; int mask = 0x80; - uint8 ch = buf[0]; + uint8_t ch = buf[0]; int extra_bytes = -1; bool all_ones = false; for (int i = 0; i < max_bytes; ++i) { @@ -466,13 +469,15 @@ static int ParseWebMElementHeaderField(const uint8* buf, int size, } if (all_ones) - *num = kint64max; + *num = std::numeric_limits<int64_t>::max(); return bytes_used; } -int WebMParseElementHeader(const uint8* buf, int size, - int* id, int64* element_size) { +int WebMParseElementHeader(const uint8_t* buf, + int size, + int* id, + int64_t* element_size) { DCHECK(buf); DCHECK_GE(size, 0); DCHECK(id); @@ -481,13 +486,13 @@ int WebMParseElementHeader(const uint8* buf, int size, if (size == 0) return 0; - int64 tmp = 0; + int64_t tmp = 0; int num_id_bytes = ParseWebMElementHeaderField(buf, size, 4, false, &tmp); if (num_id_bytes <= 0) return num_id_bytes; - if (tmp == kint64max) + if (tmp == std::numeric_limits<int64_t>::max()) tmp = kWebMReservedId; *id = static_cast<int>(tmp); @@ -499,7 +504,7 @@ int WebMParseElementHeader(const uint8* buf, int size, if (num_size_bytes <= 0) return num_size_bytes; - if (tmp == kint64max) + if (tmp == std::numeric_limits<int64_t>::max()) tmp = kWebMUnknownSize; *element_size = tmp; @@ -543,19 +548,22 @@ static int FindListLevel(int id) { return -1; } -static int ParseUInt(const uint8* buf, int size, int id, +static int ParseUInt(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { if ((size <= 0) || (size > 8)) return -1; // Read in the big-endian integer. - uint64 value = 0; + uint64_t value = 0; for (int i = 0; i < size; ++i) value = (value << 8) | buf[i]; - // We use int64 in place of uint64 everywhere for convenience. See this bug + // We use int64_t in place of uint64_t everywhere for convenience. See this + // bug // for more details: http://crbug.com/366750#c3 - if (!base::IsValueInRangeForNumericType<int64>(value)) + if (!base::IsValueInRangeForNumericType<int64_t>(value)) return -1; if (!client->OnUInt(id, value)) @@ -564,16 +572,17 @@ static int ParseUInt(const uint8* buf, int size, int id, return size; } -static int ParseFloat(const uint8* buf, int size, int id, +static int ParseFloat(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { - if ((size != 4) && (size != 8)) return -1; double value = -1; // Read the bytes from big-endian form into a native endian integer. - int64 tmp = 0; + int64_t tmp = 0; for (int i = 0; i < size; ++i) tmp = (tmp << 8) | buf[i]; @@ -581,14 +590,14 @@ static int ParseFloat(const uint8* buf, int size, int id, // number. if (size == 4) { union { - int32 src; + int32_t src; float dst; } tmp2; - tmp2.src = static_cast<int32>(tmp); + tmp2.src = static_cast<int32_t>(tmp); value = tmp2.dst; } else if (size == 8) { union { - int64 src; + int64_t src; double dst; } tmp2; tmp2.src = tmp; @@ -603,21 +612,28 @@ static int ParseFloat(const uint8* buf, int size, int id, return size; } -static int ParseBinary(const uint8* buf, int size, int id, +static int ParseBinary(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { return client->OnBinary(id, buf, size) ? size : -1; } -static int ParseString(const uint8* buf, int size, int id, +static int ParseString(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { - const uint8* end = static_cast<const uint8*>(memchr(buf, '\0', size)); + const uint8_t* end = static_cast<const uint8_t*>(memchr(buf, '\0', size)); int length = (end != NULL) ? static_cast<int>(end - buf) : size; std::string str(reinterpret_cast<const char*>(buf), length); return client->OnString(id, str) ? size : -1; } -static int ParseNonListElement(ElementType type, int id, int64 element_size, - const uint8* buf, int size, +static int ParseNonListElement(ElementType type, + int id, + int64_t element_size, + const uint8_t* buf, + int size, WebMParserClient* client) { DCHECK_GE(size, element_size); @@ -664,7 +680,7 @@ bool WebMParserClient::OnListEnd(int id) { return false; } -bool WebMParserClient::OnUInt(int id, int64 val) { +bool WebMParserClient::OnUInt(int id, int64_t val) { DVLOG(1) << "Unexpected unsigned integer element with ID " << std::hex << id; return false; } @@ -674,7 +690,7 @@ bool WebMParserClient::OnFloat(int id, double val) { return false; } -bool WebMParserClient::OnBinary(int id, const uint8* data, int size) { +bool WebMParserClient::OnBinary(int id, const uint8_t* data, int size) { DVLOG(1) << "Unexpected binary element with ID " << std::hex << id; return false; } @@ -700,7 +716,7 @@ void WebMListParser::Reset() { list_state_stack_.clear(); } -int WebMListParser::Parse(const uint8* buf, int size) { +int WebMListParser::Parse(const uint8_t* buf, int size) { DCHECK(buf); if (size < 0 || state_ == PARSE_ERROR || state_ == DONE_PARSING_LIST) @@ -709,13 +725,13 @@ int WebMListParser::Parse(const uint8* buf, int size) { if (size == 0) return 0; - const uint8* cur = buf; + const uint8_t* cur = buf; int cur_size = size; int bytes_parsed = 0; while (cur_size > 0 && state_ != PARSE_ERROR && state_ != DONE_PARSING_LIST) { int element_id = 0; - int64 element_size = 0; + int64_t element_size = 0; int result = WebMParseElementHeader(cur, cur_size, &element_id, &element_size); @@ -749,7 +765,7 @@ int WebMListParser::Parse(const uint8* buf, int size) { case INSIDE_LIST: { int header_size = result; - const uint8* element_data = cur + header_size; + const uint8_t* element_data = cur + header_size; int element_data_size = cur_size - header_size; if (element_size < element_data_size) @@ -793,8 +809,10 @@ void WebMListParser::ChangeState(State new_state) { } int WebMListParser::ParseListElement(int header_size, - int id, int64 element_size, - const uint8* data, int size) { + int id, + int64_t element_size, + const uint8_t* data, + int size) { DCHECK_GT(list_state_stack_.size(), 0u); ListState& list_state = list_state_stack_.back(); @@ -827,7 +845,7 @@ int WebMListParser::ParseListElement(int header_size, } // Make sure the whole element can fit inside the current list. - int64 total_element_size = header_size + element_size; + int64_t total_element_size = header_size + element_size; if (list_state.size_ != kWebMUnknownSize && list_state.size_ < list_state.bytes_parsed_ + total_element_size) { return -1; @@ -869,7 +887,7 @@ int WebMListParser::ParseListElement(int header_size, return result; } -bool WebMListParser::OnListStart(int id, int64 size) { +bool WebMListParser::OnListStart(int id, int64_t size) { const ListElementInfo* element_info = FindListInfo(id); if (!element_info) return false; @@ -907,7 +925,7 @@ bool WebMListParser::OnListEnd() { int lists_ended = 0; for (; !list_state_stack_.empty(); ++lists_ended) { const ListState& list_state = list_state_stack_.back(); - int64 bytes_parsed = list_state.bytes_parsed_; + int64_t bytes_parsed = list_state.bytes_parsed_; int id = list_state.id_; if (bytes_parsed != list_state.size_) diff --git a/media/formats/webm/webm_parser.h b/media/formats/webm/webm_parser.h index 854db68..3af81ea 100644 --- a/media/formats/webm/webm_parser.h +++ b/media/formats/webm/webm_parser.h @@ -5,10 +5,12 @@ #ifndef MEDIA_FORMATS_WEBM_WEBM_PARSER_H_ #define MEDIA_FORMATS_WEBM_WEBM_PARSER_H_ +#include <stdint.h> + #include <string> #include <vector> -#include "base/basictypes.h" +#include "base/macros.h" #include "media/base/media_export.h" namespace media { @@ -31,9 +33,9 @@ class MEDIA_EXPORT WebMParserClient { virtual WebMParserClient* OnListStart(int id); virtual bool OnListEnd(int id); - virtual bool OnUInt(int id, int64 val); + virtual bool OnUInt(int id, int64_t val); virtual bool OnFloat(int id, double val); - virtual bool OnBinary(int id, const uint8* data, int size); + virtual bool OnBinary(int id, const uint8_t* data, int size); virtual bool OnString(int id, const std::string& str); protected: @@ -64,7 +66,7 @@ class MEDIA_EXPORT WebMListParser { // Returns < 0 if the parse fails. // Returns 0 if more data is needed. // Returning > 0 indicates success & the number of bytes parsed. - int Parse(const uint8* buf, int size); + int Parse(const uint8_t* buf, int size); // Returns true if the entire list has been parsed. bool IsParsingComplete() const; @@ -79,8 +81,8 @@ class MEDIA_EXPORT WebMListParser { struct ListState { int id_; - int64 size_; - int64 bytes_parsed_; + int64_t size_; + int64_t bytes_parsed_; const ListElementInfo* element_info_; WebMParserClient* client_; }; @@ -100,8 +102,10 @@ class MEDIA_EXPORT WebMListParser { // Returns 0 if more data is needed. // Returning > 0 indicates success & the number of bytes parsed. int ParseListElement(int header_size, - int id, int64 element_size, - const uint8* data, int size); + int id, + int64_t element_size, + const uint8_t* data, + int size); // Called when starting to parse a new list. // @@ -111,7 +115,7 @@ class MEDIA_EXPORT WebMListParser { // // Returns true if this list can be started in the current context. False // if starting this list causes some sort of parse error. - bool OnListStart(int id, int64 size); + bool OnListStart(int id, int64_t size); // Called when the end of the current list has been reached. This may also // signal the end of the current list's ancestors if the current list happens @@ -150,8 +154,10 @@ class MEDIA_EXPORT WebMListParser { // |*id| contains the element ID on success and is undefined otherwise. // |*element_size| contains the element size on success and is undefined // otherwise. -int MEDIA_EXPORT WebMParseElementHeader(const uint8* buf, int size, - int* id, int64* element_size); +int MEDIA_EXPORT WebMParseElementHeader(const uint8_t* buf, + int size, + int* id, + int64_t* element_size); } // namespace media diff --git a/media/formats/webm/webm_parser_unittest.cc b/media/formats/webm/webm_parser_unittest.cc index a1249e8..26f5f4b 100644 --- a/media/formats/webm/webm_parser_unittest.cc +++ b/media/formats/webm/webm_parser_unittest.cc @@ -25,9 +25,9 @@ class MockWebMParserClient : public WebMParserClient { // WebMParserClient methods. MOCK_METHOD1(OnListStart, WebMParserClient*(int)); MOCK_METHOD1(OnListEnd, bool(int)); - MOCK_METHOD2(OnUInt, bool(int, int64)); + MOCK_METHOD2(OnUInt, bool(int, int64_t)); MOCK_METHOD2(OnFloat, bool(int, double)); - MOCK_METHOD3(OnBinary, bool(int, const uint8*, int)); + MOCK_METHOD3(OnBinary, bool(int, const uint8_t*, int)); MOCK_METHOD2(OnString, bool(int, const std::string&)); }; @@ -41,7 +41,7 @@ static scoped_ptr<Cluster> CreateCluster(int block_count) { cb.SetClusterTimecode(0); for (int i = 0; i < block_count; i++) { - uint8 data[] = { 0x00 }; + uint8_t data[] = {0x00}; cb.AddSimpleBlock(0, i, 0, data, sizeof(data)); } @@ -67,8 +67,8 @@ static void CreateClusterExpectations(int block_count, } TEST_F(WebMParserTest, EmptyCluster) { - const uint8 kEmptyCluster[] = { - 0x1F, 0x43, 0xB6, 0x75, 0x80 // CLUSTER (size = 0) + const uint8_t kEmptyCluster[] = { + 0x1F, 0x43, 0xB6, 0x75, 0x80 // CLUSTER (size = 0) }; int size = sizeof(kEmptyCluster); @@ -82,9 +82,9 @@ TEST_F(WebMParserTest, EmptyCluster) { } TEST_F(WebMParserTest, EmptyClusterInSegment) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) - 0x1F, 0x43, 0xB6, 0x75, 0x80, // CLUSTER (size = 0) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) + 0x1F, 0x43, 0xB6, 0x75, 0x80, // CLUSTER (size = 0) }; int size = sizeof(kBuffer); @@ -102,9 +102,9 @@ TEST_F(WebMParserTest, EmptyClusterInSegment) { // Test the case where a non-list child element has a size // that is beyond the end of the parent. TEST_F(WebMParserTest, ChildNonListLargerThanParent) { - const uint8 kBuffer[] = { - 0x1F, 0x43, 0xB6, 0x75, 0x81, // CLUSTER (size = 1) - 0xE7, 0x81, 0x01, // Timecode (size=1, value=1) + const uint8_t kBuffer[] = { + 0x1F, 0x43, 0xB6, 0x75, 0x81, // CLUSTER (size = 1) + 0xE7, 0x81, 0x01, // Timecode (size=1, value=1) }; InSequence s; @@ -118,9 +118,10 @@ TEST_F(WebMParserTest, ChildNonListLargerThanParent) { // Test the case where a list child element has a size // that is beyond the end of the parent. TEST_F(WebMParserTest, ChildListLargerThanParent) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) - 0x1F, 0x43, 0xB6, 0x75, 0x81, 0x11 // CLUSTER (size = 1) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) + 0x1F, 0x43, 0xB6, 0x75, 0x81, + 0x11 // CLUSTER (size = 1) }; InSequence s; @@ -133,8 +134,8 @@ TEST_F(WebMParserTest, ChildListLargerThanParent) { // Expecting to parse a Cluster, but get a Segment. TEST_F(WebMParserTest, ListIdDoesNotMatch) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x80, // SEGMENT (size = 0) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x80, // SEGMENT (size = 0) }; WebMListParser parser(kWebMIdCluster, &client_); @@ -143,9 +144,9 @@ TEST_F(WebMParserTest, ListIdDoesNotMatch) { } TEST_F(WebMParserTest, InvalidElementInList) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x82, // SEGMENT (size = 2) - 0xAE, 0x80, // TrackEntry (size = 0) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x82, // SEGMENT (size = 2) + 0xAE, 0x80, // TrackEntry (size = 0) }; InSequence s; @@ -159,9 +160,9 @@ TEST_F(WebMParserTest, InvalidElementInList) { // Test specific case of InvalidElementInList to verify EBMLHEADER within // known-sized cluster causes parse error. TEST_F(WebMParserTest, InvalidEBMLHeaderInCluster) { - const uint8 kBuffer[] = { - 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) - 0x1A, 0x45, 0xDF, 0xA3, 0x80, // EBMLHEADER (size = 0) + const uint8_t kBuffer[] = { + 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) + 0x1A, 0x45, 0xDF, 0xA3, 0x80, // EBMLHEADER (size = 0) }; InSequence s; @@ -174,9 +175,11 @@ TEST_F(WebMParserTest, InvalidEBMLHeaderInCluster) { // Verify that EBMLHEADER ends a preceding "unknown"-sized CLUSTER. TEST_F(WebMParserTest, UnknownSizeClusterFollowedByEBMLHeader) { - const uint8 kBuffer[] = { - 0x1F, 0x43, 0xB6, 0x75, 0xFF, // CLUSTER (size = unknown; really 0 due to:) - 0x1A, 0x45, 0xDF, 0xA3, 0x80, // EBMLHEADER (size = 0) + const uint8_t kBuffer[] = { + 0x1F, 0x43, 0xB6, + 0x75, 0xFF, // CLUSTER (size = unknown; really 0 due to:) + 0x1A, 0x45, 0xDF, + 0xA3, 0x80, // EBMLHEADER (size = 0) }; InSequence s; @@ -191,13 +194,13 @@ TEST_F(WebMParserTest, UnknownSizeClusterFollowedByEBMLHeader) { } TEST_F(WebMParserTest, VoidAndCRC32InList) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x99, // SEGMENT (size = 25) - 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) - 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) - 0x1F, 0x43, 0xB6, 0x75, 0x8A, // CLUSTER (size = 10) - 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) - 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x99, // SEGMENT (size = 25) + 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) + 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) + 0x1F, 0x43, 0xB6, 0x75, 0x8A, // CLUSTER (size = 10) + 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) + 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) }; int size = sizeof(kBuffer); @@ -226,7 +229,7 @@ TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) { scoped_ptr<Cluster> cluster(CreateCluster(kBlockCount)); CreateClusterExpectations(kBlockCount, true, &client_); - const uint8* data = cluster->data(); + const uint8_t* data = cluster->data(); int size = cluster->size(); int default_parse_size = 3; WebMListParser parser(kWebMIdCluster, &client_); @@ -283,13 +286,13 @@ TEST_F(WebMParserTest, Reset) { // Test the case where multiple clients are used for different lists. TEST_F(WebMParserTest, MultipleClients) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x94, // SEGMENT (size = 20) - 0x16, 0x54, 0xAE, 0x6B, 0x85, // TRACKS (size = 5) - 0xAE, 0x83, // TRACKENTRY (size = 3) - 0xD7, 0x81, 0x01, // TRACKNUMBER (size = 1) - 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) - 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x94, // SEGMENT (size = 20) + 0x16, 0x54, 0xAE, 0x6B, 0x85, // TRACKS (size = 5) + 0xAE, 0x83, // TRACKENTRY (size = 3) + 0xD7, 0x81, 0x01, // TRACKNUMBER (size = 1) + 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) + 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) }; int size = sizeof(kBuffer); @@ -315,9 +318,9 @@ TEST_F(WebMParserTest, MultipleClients) { // Test the case where multiple clients are used for different lists. TEST_F(WebMParserTest, InvalidClient) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 20) - 0x16, 0x54, 0xAE, 0x6B, 0x80, // TRACKS (size = 5) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 20) + 0x16, 0x54, 0xAE, 0x6B, 0x80, // TRACKS (size = 5) }; InSequence s; @@ -329,20 +332,16 @@ TEST_F(WebMParserTest, InvalidClient) { } TEST_F(WebMParserTest, ReservedIds) { - const uint8 k1ByteReservedId[] = { 0xFF, 0x81 }; - const uint8 k2ByteReservedId[] = { 0x7F, 0xFF, 0x81 }; - const uint8 k3ByteReservedId[] = { 0x3F, 0xFF, 0xFF, 0x81 }; - const uint8 k4ByteReservedId[] = { 0x1F, 0xFF, 0xFF, 0xFF, 0x81 }; - const uint8* kBuffers[] = { - k1ByteReservedId, - k2ByteReservedId, - k3ByteReservedId, - k4ByteReservedId - }; + const uint8_t k1ByteReservedId[] = {0xFF, 0x81}; + const uint8_t k2ByteReservedId[] = {0x7F, 0xFF, 0x81}; + const uint8_t k3ByteReservedId[] = {0x3F, 0xFF, 0xFF, 0x81}; + const uint8_t k4ByteReservedId[] = {0x1F, 0xFF, 0xFF, 0xFF, 0x81}; + const uint8_t* kBuffers[] = {k1ByteReservedId, k2ByteReservedId, + k3ByteReservedId, k4ByteReservedId}; for (size_t i = 0; i < arraysize(kBuffers); i++) { int id; - int64 element_size; + int64_t element_size; int buffer_size = 2 + i; EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, &id, &element_size)); @@ -352,31 +351,25 @@ TEST_F(WebMParserTest, ReservedIds) { } TEST_F(WebMParserTest, ReservedSizes) { - const uint8 k1ByteReservedSize[] = { 0xA3, 0xFF }; - const uint8 k2ByteReservedSize[] = { 0xA3, 0x7F, 0xFF }; - const uint8 k3ByteReservedSize[] = { 0xA3, 0x3F, 0xFF, 0xFF }; - const uint8 k4ByteReservedSize[] = { 0xA3, 0x1F, 0xFF, 0xFF, 0xFF }; - const uint8 k5ByteReservedSize[] = { 0xA3, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF }; - const uint8 k6ByteReservedSize[] = { 0xA3, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF }; - const uint8 k7ByteReservedSize[] = { 0xA3, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF }; - const uint8 k8ByteReservedSize[] = { 0xA3, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF }; - const uint8* kBuffers[] = { - k1ByteReservedSize, - k2ByteReservedSize, - k3ByteReservedSize, - k4ByteReservedSize, - k5ByteReservedSize, - k6ByteReservedSize, - k7ByteReservedSize, - k8ByteReservedSize - }; + const uint8_t k1ByteReservedSize[] = {0xA3, 0xFF}; + const uint8_t k2ByteReservedSize[] = {0xA3, 0x7F, 0xFF}; + const uint8_t k3ByteReservedSize[] = {0xA3, 0x3F, 0xFF, 0xFF}; + const uint8_t k4ByteReservedSize[] = {0xA3, 0x1F, 0xFF, 0xFF, 0xFF}; + const uint8_t k5ByteReservedSize[] = {0xA3, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF}; + const uint8_t k6ByteReservedSize[] = {0xA3, 0x07, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF}; + const uint8_t k7ByteReservedSize[] = {0xA3, 0x03, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; + const uint8_t k8ByteReservedSize[] = {0xA3, 0x01, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; + const uint8_t* kBuffers[] = {k1ByteReservedSize, k2ByteReservedSize, + k3ByteReservedSize, k4ByteReservedSize, + k5ByteReservedSize, k6ByteReservedSize, + k7ByteReservedSize, k8ByteReservedSize}; for (size_t i = 0; i < arraysize(kBuffers); i++) { int id; - int64 element_size; + int64_t element_size; int buffer_size = 2 + i; EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, &id, &element_size)); @@ -386,12 +379,13 @@ TEST_F(WebMParserTest, ReservedSizes) { } TEST_F(WebMParserTest, ZeroPaddedStrings) { - const uint8 kBuffer[] = { - 0x1A, 0x45, 0xDF, 0xA3, 0x91, // EBMLHEADER (size = 17) - 0x42, 0x82, 0x80, // DocType (size = 0) - 0x42, 0x82, 0x81, 0x00, // DocType (size = 1) "" - 0x42, 0x82, 0x81, 'a', // DocType (size = 1) "a" - 0x42, 0x82, 0x83, 'a', 0x00, 0x00 // DocType (size = 3) "a" + const uint8_t kBuffer[] = { + 0x1A, 0x45, 0xDF, 0xA3, 0x91, // EBMLHEADER (size = 17) + 0x42, 0x82, 0x80, // DocType (size = 0) + 0x42, 0x82, 0x81, 0x00, // DocType (size = 1) "" + 0x42, 0x82, 0x81, 'a', // DocType (size = 1) "a" + 0x42, 0x82, 0x83, 'a', 0x00, + 0x00 // DocType (size = 3) "a" }; int size = sizeof(kBuffer); |