Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t. BUG=webrtc:5024 R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org Review URL: https://codereview.webrtc.org/1362503003 . Cr-Commit-Position: refs/heads/master@{#10196}
This commit is contained in:
parent
8d15bd6dab
commit
0c4e06b4c6
@ -50,13 +50,13 @@ class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory {
|
||||
captured_frame_.pixel_width = 1;
|
||||
captured_frame_.data = nullptr;
|
||||
captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize;
|
||||
captured_frame_.fourcc = static_cast<uint32>(cricket::FOURCC_ANY);
|
||||
captured_frame_.fourcc = static_cast<uint32_t>(cricket::FOURCC_ANY);
|
||||
}
|
||||
|
||||
void UpdateCapturedFrame(
|
||||
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
|
||||
int rotation,
|
||||
int64 time_stamp_in_ns) {
|
||||
int64_t time_stamp_in_ns) {
|
||||
buffer_ = buffer;
|
||||
captured_frame_.width = buffer->width();
|
||||
captured_frame_.height = buffer->height();
|
||||
@ -169,7 +169,7 @@ bool AndroidVideoCapturer::IsRunning() {
|
||||
return running_;
|
||||
}
|
||||
|
||||
bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
|
||||
bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
|
||||
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
||||
fourccs->push_back(cricket::FOURCC_YV12);
|
||||
return true;
|
||||
@ -192,7 +192,7 @@ void AndroidVideoCapturer::OnCapturerStarted(bool success) {
|
||||
void AndroidVideoCapturer::OnIncomingFrame(
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer,
|
||||
int rotation,
|
||||
int64 time_stamp) {
|
||||
int64_t time_stamp) {
|
||||
RTC_CHECK(thread_checker_.CalledOnValidThread());
|
||||
frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp);
|
||||
SignalFrameCaptured(this, frame_factory_->GetCapturedFrame());
|
||||
|
||||
@ -69,7 +69,7 @@ class AndroidVideoCapturer : public cricket::VideoCapturer {
|
||||
// Argument |buffer| is intentionally by value, for use with rtc::Bind.
|
||||
void OnIncomingFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer,
|
||||
int rotation,
|
||||
int64 time_stamp);
|
||||
int64_t time_stamp);
|
||||
|
||||
// Called from JNI to request a new video format.
|
||||
void OnOutputFormatRequest(int width, int height, int fps);
|
||||
@ -89,7 +89,7 @@ class AndroidVideoCapturer : public cricket::VideoCapturer {
|
||||
void Stop() override;
|
||||
bool IsRunning() override;
|
||||
bool IsScreencast() const override { return false; }
|
||||
bool GetPreferredFourccs(std::vector<uint32>* fourccs) override;
|
||||
bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override;
|
||||
|
||||
bool running_;
|
||||
rtc::scoped_refptr<AndroidVideoCapturerDelegate> delegate_;
|
||||
|
||||
@ -193,7 +193,7 @@ bool DataChannel::reliable() const {
|
||||
}
|
||||
}
|
||||
|
||||
uint64 DataChannel::buffered_amount() const {
|
||||
uint64_t DataChannel::buffered_amount() const {
|
||||
return queued_send_data_.byte_count();
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ bool DataChannel::Send(const DataBuffer& buffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DataChannel::SetReceiveSsrc(uint32 receive_ssrc) {
|
||||
void DataChannel::SetReceiveSsrc(uint32_t receive_ssrc) {
|
||||
ASSERT(data_channel_type_ == cricket::DCT_RTP);
|
||||
|
||||
if (receive_ssrc_set_) {
|
||||
@ -276,7 +276,7 @@ void DataChannel::OnTransportChannelCreated() {
|
||||
}
|
||||
}
|
||||
|
||||
void DataChannel::SetSendSsrc(uint32 send_ssrc) {
|
||||
void DataChannel::SetSendSsrc(uint32_t send_ssrc) {
|
||||
ASSERT(data_channel_type_ == cricket::DCT_RTP);
|
||||
if (send_ssrc_set_) {
|
||||
return;
|
||||
@ -304,7 +304,7 @@ void DataChannel::OnDataEngineClose() {
|
||||
void DataChannel::OnDataReceived(cricket::DataChannel* channel,
|
||||
const cricket::ReceiveDataParams& params,
|
||||
const rtc::Buffer& payload) {
|
||||
uint32 expected_ssrc =
|
||||
uint32_t expected_ssrc =
|
||||
(data_channel_type_ == cricket::DCT_RTP) ? receive_ssrc_ : config_.id;
|
||||
if (params.ssrc != expected_ssrc) {
|
||||
return;
|
||||
@ -476,7 +476,7 @@ void DataChannel::SendQueuedDataMessages() {
|
||||
|
||||
ASSERT(state_ == kOpen || state_ == kClosing);
|
||||
|
||||
uint64 start_buffered_amount = buffered_amount();
|
||||
uint64_t start_buffered_amount = buffered_amount();
|
||||
while (!queued_send_data_.Empty()) {
|
||||
DataBuffer* buffer = queued_send_data_.Front();
|
||||
if (!SendDataMessage(*buffer, false)) {
|
||||
|
||||
@ -114,16 +114,14 @@ class DataChannel : public DataChannelInterface,
|
||||
virtual std::string label() const { return label_; }
|
||||
virtual bool reliable() const;
|
||||
virtual bool ordered() const { return config_.ordered; }
|
||||
virtual uint16 maxRetransmitTime() const {
|
||||
virtual uint16_t maxRetransmitTime() const {
|
||||
return config_.maxRetransmitTime;
|
||||
}
|
||||
virtual uint16 maxRetransmits() const {
|
||||
return config_.maxRetransmits;
|
||||
}
|
||||
virtual uint16_t maxRetransmits() const { return config_.maxRetransmits; }
|
||||
virtual std::string protocol() const { return config_.protocol; }
|
||||
virtual bool negotiated() const { return config_.negotiated; }
|
||||
virtual int id() const { return config_.id; }
|
||||
virtual uint64 buffered_amount() const;
|
||||
virtual uint64_t buffered_amount() const;
|
||||
virtual void Close();
|
||||
virtual DataState state() const { return state_; }
|
||||
virtual bool Send(const DataBuffer& buffer);
|
||||
@ -160,10 +158,10 @@ class DataChannel : public DataChannelInterface,
|
||||
// Set the SSRC this channel should use to send data on the
|
||||
// underlying data engine. |send_ssrc| == 0 means that the channel is no
|
||||
// longer part of the session negotiation.
|
||||
void SetSendSsrc(uint32 send_ssrc);
|
||||
void SetSendSsrc(uint32_t send_ssrc);
|
||||
// Set the SSRC this channel should use to receive data from the
|
||||
// underlying data engine.
|
||||
void SetReceiveSsrc(uint32 receive_ssrc);
|
||||
void SetReceiveSsrc(uint32_t receive_ssrc);
|
||||
|
||||
cricket::DataChannelType data_channel_type() const {
|
||||
return data_channel_type_;
|
||||
@ -240,8 +238,8 @@ class DataChannel : public DataChannelInterface,
|
||||
bool send_ssrc_set_;
|
||||
bool receive_ssrc_set_;
|
||||
bool writable_;
|
||||
uint32 send_ssrc_;
|
||||
uint32 receive_ssrc_;
|
||||
uint32_t send_ssrc_;
|
||||
uint32_t receive_ssrc_;
|
||||
// Control messages that always have to get sent out before any queued
|
||||
// data.
|
||||
PacketQueue queued_control_data_;
|
||||
@ -266,13 +264,13 @@ BEGIN_PROXY_MAP(DataChannel)
|
||||
PROXY_CONSTMETHOD0(std::string, label)
|
||||
PROXY_CONSTMETHOD0(bool, reliable)
|
||||
PROXY_CONSTMETHOD0(bool, ordered)
|
||||
PROXY_CONSTMETHOD0(uint16, maxRetransmitTime)
|
||||
PROXY_CONSTMETHOD0(uint16, maxRetransmits)
|
||||
PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime)
|
||||
PROXY_CONSTMETHOD0(uint16_t, maxRetransmits)
|
||||
PROXY_CONSTMETHOD0(std::string, protocol)
|
||||
PROXY_CONSTMETHOD0(bool, negotiated)
|
||||
PROXY_CONSTMETHOD0(int, id)
|
||||
PROXY_CONSTMETHOD0(DataState, state)
|
||||
PROXY_CONSTMETHOD0(uint64, buffered_amount)
|
||||
PROXY_CONSTMETHOD0(uint64_t, buffered_amount)
|
||||
PROXY_METHOD0(void, Close)
|
||||
PROXY_METHOD1(bool, Send, const DataBuffer&)
|
||||
END_PROXY()
|
||||
|
||||
@ -43,7 +43,7 @@ class FakeDataChannelObserver : public webrtc::DataChannelObserver {
|
||||
++on_state_change_count_;
|
||||
}
|
||||
|
||||
void OnBufferedAmountChange(uint64 previous_amount) {
|
||||
void OnBufferedAmountChange(uint64_t previous_amount) {
|
||||
++on_buffered_amount_change_count_;
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ TEST_F(SctpDataChannelTest, OpenMessageSent) {
|
||||
EXPECT_GE(webrtc_data_channel_->id(), 0);
|
||||
EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type);
|
||||
EXPECT_EQ(provider_.last_send_data_params().ssrc,
|
||||
static_cast<uint32>(webrtc_data_channel_->id()));
|
||||
static_cast<uint32_t>(webrtc_data_channel_->id()));
|
||||
}
|
||||
|
||||
TEST_F(SctpDataChannelTest, QueuedOpenMessageSent) {
|
||||
@ -225,7 +225,7 @@ TEST_F(SctpDataChannelTest, QueuedOpenMessageSent) {
|
||||
|
||||
EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type);
|
||||
EXPECT_EQ(provider_.last_send_data_params().ssrc,
|
||||
static_cast<uint32>(webrtc_data_channel_->id()));
|
||||
static_cast<uint32_t>(webrtc_data_channel_->id()));
|
||||
}
|
||||
|
||||
// Tests that the DataChannel created after transport gets ready can enter OPEN
|
||||
|
||||
@ -92,7 +92,7 @@ class DataChannelObserver {
|
||||
// A data buffer was successfully received.
|
||||
virtual void OnMessage(const DataBuffer& buffer) = 0;
|
||||
// The data channel's buffered_amount has changed.
|
||||
virtual void OnBufferedAmountChange(uint64 previous_amount){};
|
||||
virtual void OnBufferedAmountChange(uint64_t previous_amount){};
|
||||
|
||||
protected:
|
||||
virtual ~DataChannelObserver() {}
|
||||
@ -135,8 +135,8 @@ class DataChannelInterface : public rtc::RefCountInterface {
|
||||
// implemented these APIs. They should all just return the values the
|
||||
// DataChannel was created with.
|
||||
virtual bool ordered() const { return false; }
|
||||
virtual uint16 maxRetransmitTime() const { return 0; }
|
||||
virtual uint16 maxRetransmits() const { return 0; }
|
||||
virtual uint16_t maxRetransmitTime() const { return 0; }
|
||||
virtual uint16_t maxRetransmits() const { return 0; }
|
||||
virtual std::string protocol() const { return std::string(); }
|
||||
virtual bool negotiated() const { return false; }
|
||||
|
||||
@ -145,7 +145,7 @@ class DataChannelInterface : public rtc::RefCountInterface {
|
||||
// The buffered_amount returns the number of bytes of application data
|
||||
// (UTF-8 text and binary data) that have been queued using SendBuffer but
|
||||
// have not yet been transmitted to the network.
|
||||
virtual uint64 buffered_amount() const = 0;
|
||||
virtual uint64_t buffered_amount() const = 0;
|
||||
virtual void Close() = 0;
|
||||
// Sends |data| to the remote peer.
|
||||
virtual bool Send(const DataBuffer& buffer) = 0;
|
||||
|
||||
@ -132,7 +132,7 @@ class FakeDtmfProvider : public DtmfProviderInterface {
|
||||
private:
|
||||
std::set<std::string> can_insert_dtmf_tracks_;
|
||||
std::vector<DtmfInfo> dtmf_info_queue_;
|
||||
int64 last_insert_dtmf_call_;
|
||||
int64_t last_insert_dtmf_call_;
|
||||
sigslot::signal0<> SignalDestroyed;
|
||||
};
|
||||
|
||||
|
||||
@ -519,10 +519,10 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread(
|
||||
|
||||
// Copy encoded data to Java ByteBuffer.
|
||||
jobject j_input_buffer = input_buffers_[j_input_buffer_index];
|
||||
uint8* buffer =
|
||||
reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer));
|
||||
uint8_t* buffer =
|
||||
reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_input_buffer));
|
||||
RTC_CHECK(buffer) << "Indirect buffer??";
|
||||
int64 buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer);
|
||||
int64_t buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer);
|
||||
if (CheckException(jni) || buffer_capacity < inputImage._length) {
|
||||
ALOGE("Input frame size %d is bigger than buffer size %d.",
|
||||
inputImage._length, buffer_capacity);
|
||||
|
||||
@ -487,7 +487,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread(
|
||||
for (size_t i = 0; i < num_input_buffers; ++i) {
|
||||
input_buffers_[i] =
|
||||
jni->NewGlobalRef(jni->GetObjectArrayElement(input_buffers, i));
|
||||
int64 yuv_buffer_capacity =
|
||||
int64_t yuv_buffer_capacity =
|
||||
jni->GetDirectBufferCapacity(input_buffers_[i]);
|
||||
CHECK_EXCEPTION(jni);
|
||||
RTC_CHECK(yuv_buffer_capacity >= yuv_size_) << "Insufficient capacity";
|
||||
@ -572,8 +572,8 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread(
|
||||
frames_received_ - 1, current_timestamp_us_ / 1000, frames_in_queue_);
|
||||
|
||||
jobject j_input_buffer = input_buffers_[j_input_buffer_index];
|
||||
uint8* yuv_buffer =
|
||||
reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer));
|
||||
uint8_t* yuv_buffer =
|
||||
reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_input_buffer));
|
||||
CHECK_EXCEPTION(jni);
|
||||
RTC_CHECK(yuv_buffer) << "Indirect buffer??";
|
||||
RTC_CHECK(!libyuv::ConvertFromI420(
|
||||
@ -726,7 +726,7 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
|
||||
|
||||
// Extract payload.
|
||||
size_t payload_size = jni->GetDirectBufferCapacity(j_output_buffer);
|
||||
uint8* payload = reinterpret_cast<uint8_t*>(
|
||||
uint8_t* payload = reinterpret_cast<uint8_t*>(
|
||||
jni->GetDirectBufferAddress(j_output_buffer));
|
||||
CHECK_EXCEPTION(jni);
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ void AndroidVideoCapturerJni::AsyncCapturerInvoke(
|
||||
invoker_->AsyncInvoke<void>(rtc::Bind(method, capturer_, args...));
|
||||
}
|
||||
|
||||
void AndroidVideoCapturerJni::ReturnBuffer(int64 time_stamp) {
|
||||
void AndroidVideoCapturerJni::ReturnBuffer(int64_t time_stamp) {
|
||||
jmethodID m = GetMethodID(jni(), *j_video_capturer_class_,
|
||||
"returnBuffer", "(J)V");
|
||||
jni()->CallVoidMethod(*j_capturer_global_, m, time_stamp);
|
||||
@ -155,7 +155,7 @@ void AndroidVideoCapturerJni::OnIncomingFrame(void* video_frame,
|
||||
int width,
|
||||
int height,
|
||||
int rotation,
|
||||
int64 time_stamp) {
|
||||
int64_t time_stamp) {
|
||||
const uint8_t* y_plane = static_cast<uint8_t*>(video_frame);
|
||||
// Android guarantees that the stride is a multiple of 16.
|
||||
// http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPreviewFormat%28int%29
|
||||
|
||||
@ -61,14 +61,14 @@ class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate {
|
||||
int width,
|
||||
int height,
|
||||
int rotation,
|
||||
int64 time_stamp);
|
||||
int64_t time_stamp);
|
||||
void OnOutputFormatRequest(int width, int height, int fps);
|
||||
|
||||
protected:
|
||||
~AndroidVideoCapturerJni();
|
||||
|
||||
private:
|
||||
void ReturnBuffer(int64 time_stamp);
|
||||
void ReturnBuffer(int64_t time_stamp);
|
||||
JNIEnv* jni();
|
||||
|
||||
// Helper function to make safe asynchronous calls to |capturer_|. The calls
|
||||
|
||||
@ -606,7 +606,7 @@ class DataChannelObserverWrapper : public DataChannelObserver {
|
||||
|
||||
virtual ~DataChannelObserverWrapper() {}
|
||||
|
||||
void OnBufferedAmountChange(uint64 previous_amount) override {
|
||||
void OnBufferedAmountChange(uint64_t previous_amount) override {
|
||||
ScopedLocalRefFrame local_ref_frame(jni());
|
||||
jni()->CallVoidMethod(*j_observer_global_, j_on_buffered_amount_change_mid_,
|
||||
previous_amount);
|
||||
@ -806,13 +806,13 @@ class JavaVideoRendererWrapper : public VideoRendererInterface {
|
||||
strides_array[2] = frame->GetVPitch();
|
||||
jni()->ReleaseIntArrayElements(strides, strides_array, 0);
|
||||
jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL);
|
||||
jobject y_buffer = jni()->NewDirectByteBuffer(
|
||||
const_cast<uint8*>(frame->GetYPlane()),
|
||||
frame->GetYPitch() * frame->GetHeight());
|
||||
jobject y_buffer =
|
||||
jni()->NewDirectByteBuffer(const_cast<uint8_t*>(frame->GetYPlane()),
|
||||
frame->GetYPitch() * frame->GetHeight());
|
||||
jobject u_buffer = jni()->NewDirectByteBuffer(
|
||||
const_cast<uint8*>(frame->GetUPlane()), frame->GetChromaSize());
|
||||
const_cast<uint8_t*>(frame->GetUPlane()), frame->GetChromaSize());
|
||||
jobject v_buffer = jni()->NewDirectByteBuffer(
|
||||
const_cast<uint8*>(frame->GetVPlane()), frame->GetChromaSize());
|
||||
const_cast<uint8_t*>(frame->GetVPlane()), frame->GetChromaSize());
|
||||
jni()->SetObjectArrayElement(planes, 0, y_buffer);
|
||||
jni()->SetObjectArrayElement(planes, 1, u_buffer);
|
||||
jni()->SetObjectArrayElement(planes, 2, v_buffer);
|
||||
@ -880,8 +880,8 @@ JOW(jobject, DataChannel_state)(JNIEnv* jni, jobject j_dc) {
|
||||
}
|
||||
|
||||
JOW(jlong, DataChannel_bufferedAmount)(JNIEnv* jni, jobject j_dc) {
|
||||
uint64 buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount();
|
||||
RTC_CHECK_LE(buffered_amount, std::numeric_limits<int64>::max())
|
||||
uint64_t buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount();
|
||||
RTC_CHECK_LE(buffered_amount, std::numeric_limits<int64_t>::max())
|
||||
<< "buffered_amount overflowed jlong!";
|
||||
return static_cast<jlong>(buffered_amount);
|
||||
}
|
||||
|
||||
@ -55,17 +55,19 @@ namespace webrtc {
|
||||
class AudioProviderInterface {
|
||||
public:
|
||||
// Enable/disable the audio playout of a remote audio track with |ssrc|.
|
||||
virtual void SetAudioPlayout(uint32 ssrc, bool enable,
|
||||
virtual void SetAudioPlayout(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::AudioRenderer* renderer) = 0;
|
||||
// Enable/disable sending audio on the local audio track with |ssrc|.
|
||||
// When |enable| is true |options| should be applied to the audio track.
|
||||
virtual void SetAudioSend(uint32 ssrc, bool enable,
|
||||
virtual void SetAudioSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::AudioOptions& options,
|
||||
cricket::AudioRenderer* renderer) = 0;
|
||||
|
||||
// Sets the audio playout volume of a remote audio track with |ssrc|.
|
||||
// |volume| is in the range of [0, 10].
|
||||
virtual void SetAudioPlayoutVolume(uint32 ssrc, double volume) = 0;
|
||||
virtual void SetAudioPlayoutVolume(uint32_t ssrc, double volume) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~AudioProviderInterface() {}
|
||||
@ -76,13 +78,15 @@ class AudioProviderInterface {
|
||||
// PeerConnection.
|
||||
class VideoProviderInterface {
|
||||
public:
|
||||
virtual bool SetCaptureDevice(uint32 ssrc,
|
||||
virtual bool SetCaptureDevice(uint32_t ssrc,
|
||||
cricket::VideoCapturer* camera) = 0;
|
||||
// Enable/disable the video playout of a remote video track with |ssrc|.
|
||||
virtual void SetVideoPlayout(uint32 ssrc, bool enable,
|
||||
virtual void SetVideoPlayout(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::VideoRenderer* renderer) = 0;
|
||||
// Enable sending video on the local video track with |ssrc|.
|
||||
virtual void SetVideoSend(uint32 ssrc, bool enable,
|
||||
virtual void SetVideoSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::VideoOptions* options) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@ -612,7 +612,7 @@ void MediaStreamSignaling::UpdateRemoteStreamsList(
|
||||
// track id.
|
||||
const std::string& stream_label = it->sync_label;
|
||||
const std::string& track_id = it->id;
|
||||
uint32 ssrc = it->first_ssrc();
|
||||
uint32_t ssrc = it->first_ssrc();
|
||||
|
||||
rtc::scoped_refptr<MediaStreamInterface> stream =
|
||||
remote_streams_->find(stream_label);
|
||||
@ -634,7 +634,7 @@ void MediaStreamSignaling::UpdateRemoteStreamsList(
|
||||
|
||||
void MediaStreamSignaling::OnRemoteTrackSeen(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
cricket::MediaType media_type) {
|
||||
MediaStreamInterface* stream = remote_streams_->find(stream_label);
|
||||
|
||||
@ -801,7 +801,7 @@ void MediaStreamSignaling::UpdateLocalTracks(
|
||||
// track id.
|
||||
const std::string& stream_label = it->sync_label;
|
||||
const std::string& track_id = it->id;
|
||||
uint32 ssrc = it->first_ssrc();
|
||||
uint32_t ssrc = it->first_ssrc();
|
||||
const TrackInfo* track_info = FindTrackInfo(*current_tracks,
|
||||
stream_label,
|
||||
track_id);
|
||||
@ -814,7 +814,7 @@ void MediaStreamSignaling::UpdateLocalTracks(
|
||||
|
||||
void MediaStreamSignaling::OnLocalTrackSeen(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
cricket::MediaType media_type) {
|
||||
MediaStreamInterface* stream = local_streams_->find(stream_label);
|
||||
if (!stream) {
|
||||
@ -844,11 +844,10 @@ void MediaStreamSignaling::OnLocalTrackSeen(const std::string& stream_label,
|
||||
}
|
||||
}
|
||||
|
||||
void MediaStreamSignaling::OnLocalTrackRemoved(
|
||||
const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc,
|
||||
cricket::MediaType media_type) {
|
||||
void MediaStreamSignaling::OnLocalTrackRemoved(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32_t ssrc,
|
||||
cricket::MediaType media_type) {
|
||||
MediaStreamInterface* stream = local_streams_->find(stream_label);
|
||||
if (!stream) {
|
||||
// This is the normal case. Ie RemoveLocalStream has been called and the
|
||||
@ -953,7 +952,7 @@ void MediaStreamSignaling::UpdateClosingDataChannels(
|
||||
}
|
||||
|
||||
void MediaStreamSignaling::CreateRemoteDataChannel(const std::string& label,
|
||||
uint32 remote_ssrc) {
|
||||
uint32_t remote_ssrc) {
|
||||
if (!data_channel_factory_) {
|
||||
LOG(LS_WARNING) << "Remote peer requested a DataChannel but DataChannels "
|
||||
<< "are not supported.";
|
||||
@ -991,8 +990,7 @@ void MediaStreamSignaling::OnDtlsRoleReadyForSctp(rtc::SSLRole role) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32 sid) {
|
||||
void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32_t sid) {
|
||||
int index = FindDataChannelBySid(sid);
|
||||
if (index < 0) {
|
||||
LOG(LS_WARNING) << "Unexpected sid " << sid
|
||||
|
||||
@ -66,12 +66,12 @@ class MediaStreamSignalingObserver {
|
||||
// Triggered when the remote SessionDescription has a new audio track.
|
||||
virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) = 0;
|
||||
uint32_t ssrc) = 0;
|
||||
|
||||
// Triggered when the remote SessionDescription has a new video track.
|
||||
virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) = 0;
|
||||
uint32_t ssrc) = 0;
|
||||
|
||||
// Triggered when the remote SessionDescription has removed an audio track.
|
||||
virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream,
|
||||
@ -84,17 +84,17 @@ class MediaStreamSignalingObserver {
|
||||
// Triggered when the local SessionDescription has a new audio track.
|
||||
virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) = 0;
|
||||
uint32_t ssrc) = 0;
|
||||
|
||||
// Triggered when the local SessionDescription has a new video track.
|
||||
virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) = 0;
|
||||
uint32_t ssrc) = 0;
|
||||
|
||||
// Triggered when the local SessionDescription has removed an audio track.
|
||||
virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) = 0;
|
||||
uint32_t ssrc) = 0;
|
||||
|
||||
// Triggered when the local SessionDescription has removed a video track.
|
||||
virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream,
|
||||
@ -254,7 +254,7 @@ class MediaStreamSignaling : public sigslot::has_slots<> {
|
||||
}
|
||||
void OnDataTransportCreatedForSctp();
|
||||
void OnDtlsRoleReadyForSctp(rtc::SSLRole role);
|
||||
void OnRemoteSctpDataChannelClosed(uint32 sid);
|
||||
void OnRemoteSctpDataChannelClosed(uint32_t sid);
|
||||
|
||||
const SctpDataChannels& sctp_data_channels() const {
|
||||
return sctp_data_channels_;
|
||||
@ -286,11 +286,11 @@ class MediaStreamSignaling : public sigslot::has_slots<> {
|
||||
TrackInfo() : ssrc(0) {}
|
||||
TrackInfo(const std::string& stream_label,
|
||||
const std::string track_id,
|
||||
uint32 ssrc)
|
||||
uint32_t ssrc)
|
||||
: stream_label(stream_label), track_id(track_id), ssrc(ssrc) {}
|
||||
std::string stream_label;
|
||||
std::string track_id;
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
};
|
||||
typedef std::vector<TrackInfo> TrackInfos;
|
||||
|
||||
@ -309,7 +309,7 @@ class MediaStreamSignaling : public sigslot::has_slots<> {
|
||||
// MediaStreamSignaling::OnAddRemoteVideoTrack.
|
||||
void OnRemoteTrackSeen(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
cricket::MediaType media_type);
|
||||
|
||||
// Triggered when a remote track has been removed from a remote session
|
||||
@ -350,7 +350,7 @@ class MediaStreamSignaling : public sigslot::has_slots<> {
|
||||
// |local_streams_|
|
||||
void OnLocalTrackSeen(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
cricket::MediaType media_type);
|
||||
|
||||
// Triggered when a local track has been removed from a local session
|
||||
@ -361,14 +361,14 @@ class MediaStreamSignaling : public sigslot::has_slots<> {
|
||||
// MediaStreamTrack in a MediaStream in |local_streams_|.
|
||||
void OnLocalTrackRemoved(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
cricket::MediaType media_type);
|
||||
|
||||
void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams);
|
||||
void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams);
|
||||
void UpdateClosingDataChannels(
|
||||
const std::vector<std::string>& active_channels, bool is_local_update);
|
||||
void CreateRemoteDataChannel(const std::string& label, uint32 remote_ssrc);
|
||||
void CreateRemoteDataChannel(const std::string& label, uint32_t remote_ssrc);
|
||||
|
||||
const TrackInfo* FindTrackInfo(const TrackInfos& infos,
|
||||
const std::string& stream_label,
|
||||
|
||||
@ -311,19 +311,19 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver {
|
||||
|
||||
virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
AddTrack(&local_audio_tracks_, stream, audio_track, ssrc);
|
||||
}
|
||||
|
||||
virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
AddTrack(&local_video_tracks_, stream, video_track, ssrc);
|
||||
}
|
||||
|
||||
virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
RemoveTrack(&local_audio_tracks_, stream, audio_track);
|
||||
}
|
||||
|
||||
@ -334,13 +334,13 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver {
|
||||
|
||||
virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
AddTrack(&remote_audio_tracks_, stream, audio_track, ssrc);
|
||||
}
|
||||
|
||||
virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
AddTrack(&remote_video_tracks_, stream, video_track, ssrc);
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver {
|
||||
|
||||
void VerifyRemoteAudioTrack(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
VerifyTrack(remote_audio_tracks_, stream_label, track_id, ssrc);
|
||||
}
|
||||
|
||||
@ -377,14 +377,14 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver {
|
||||
|
||||
void VerifyRemoteVideoTrack(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
VerifyTrack(remote_video_tracks_, stream_label, track_id, ssrc);
|
||||
}
|
||||
|
||||
size_t NumberOfLocalAudioTracks() { return local_audio_tracks_.size(); }
|
||||
void VerifyLocalAudioTrack(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
VerifyTrack(local_audio_tracks_, stream_label, track_id, ssrc);
|
||||
}
|
||||
|
||||
@ -392,7 +392,7 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver {
|
||||
|
||||
void VerifyLocalVideoTrack(const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
VerifyTrack(local_video_tracks_, stream_label, track_id, ssrc);
|
||||
}
|
||||
|
||||
@ -401,18 +401,18 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver {
|
||||
TrackInfo() {}
|
||||
TrackInfo(const std::string& stream_label,
|
||||
const std::string track_id,
|
||||
uint32 ssrc)
|
||||
uint32_t ssrc)
|
||||
: stream_label(stream_label), track_id(track_id), ssrc(ssrc) {}
|
||||
std::string stream_label;
|
||||
std::string track_id;
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
};
|
||||
typedef std::vector<TrackInfo> TrackInfos;
|
||||
|
||||
void AddTrack(TrackInfos* track_infos,
|
||||
MediaStreamInterface* stream,
|
||||
MediaStreamTrackInterface* track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
(*track_infos).push_back(TrackInfo(stream->label(), track->id(), ssrc));
|
||||
}
|
||||
|
||||
@ -442,7 +442,7 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver {
|
||||
void VerifyTrack(const TrackInfos& track_infos,
|
||||
const std::string& stream_label,
|
||||
const std::string& track_id,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
const TrackInfo* track_info = FindTrackInfo(track_infos,
|
||||
stream_label,
|
||||
track_id);
|
||||
|
||||
@ -43,7 +43,7 @@ class RTCDataChannelObserver : public DataChannelObserver {
|
||||
[_channel.delegate channelDidChangeState:_channel];
|
||||
}
|
||||
|
||||
void OnBufferedAmountChange(uint64 previousAmount) override {
|
||||
void OnBufferedAmountChange(uint64_t previousAmount) override {
|
||||
RTCDataChannel* channel = _channel;
|
||||
id<RTCDataChannelDelegate> delegate = channel.delegate;
|
||||
if ([delegate
|
||||
|
||||
@ -49,7 +49,7 @@ class AVFoundationVideoCapturer : public cricket::VideoCapturer {
|
||||
bool IsScreencast() const override {
|
||||
return false;
|
||||
}
|
||||
bool GetPreferredFourccs(std::vector<uint32>* fourccs) override {
|
||||
bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override {
|
||||
fourccs->push_back(cricket::FOURCC_NV12);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -415,13 +415,13 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer(
|
||||
uvPlaneAddress == yPlaneAddress + yPlaneHeight * yPlaneBytesPerRow);
|
||||
|
||||
// Stuff data into a cricket::CapturedFrame.
|
||||
int64 currentTime = rtc::TimeNanos();
|
||||
int64_t currentTime = rtc::TimeNanos();
|
||||
cricket::CapturedFrame frame;
|
||||
frame.width = yPlaneWidth;
|
||||
frame.height = yPlaneHeight;
|
||||
frame.pixel_width = 1;
|
||||
frame.pixel_height = 1;
|
||||
frame.fourcc = static_cast<uint32>(cricket::FOURCC_NV12);
|
||||
frame.fourcc = static_cast<uint32_t>(cricket::FOURCC_NV12);
|
||||
frame.time_stamp = currentTime;
|
||||
frame.data = yPlaneAddress;
|
||||
frame.data_size = frameSize;
|
||||
|
||||
@ -862,13 +862,13 @@ void PeerConnection::OnAddDataChannel(DataChannelInterface* data_channel) {
|
||||
|
||||
void PeerConnection::OnAddRemoteAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get()));
|
||||
}
|
||||
|
||||
void PeerConnection::OnAddRemoteVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
receivers_.push_back(new VideoRtpReceiver(video_track, ssrc, session_.get()));
|
||||
}
|
||||
|
||||
@ -902,14 +902,14 @@ void PeerConnection::OnRemoveRemoteVideoTrack(
|
||||
|
||||
void PeerConnection::OnAddLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
senders_.push_back(new AudioRtpSender(audio_track, ssrc, session_.get()));
|
||||
stats_->AddLocalAudioTrack(audio_track, ssrc);
|
||||
}
|
||||
|
||||
void PeerConnection::OnAddLocalVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
senders_.push_back(new VideoRtpSender(video_track, ssrc, session_.get()));
|
||||
}
|
||||
|
||||
@ -917,7 +917,7 @@ void PeerConnection::OnAddLocalVideoTrack(MediaStreamInterface* stream,
|
||||
// description.
|
||||
void PeerConnection::OnRemoveLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
auto it = FindSenderForTrack(audio_track);
|
||||
if (it == senders_.end()) {
|
||||
LOG(LS_WARNING) << "RtpSender for track with id " << audio_track->id()
|
||||
|
||||
@ -133,23 +133,23 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
void OnAddDataChannel(DataChannelInterface* data_channel) override;
|
||||
void OnAddRemoteAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) override;
|
||||
uint32_t ssrc) override;
|
||||
void OnAddRemoteVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) override;
|
||||
uint32_t ssrc) override;
|
||||
void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track) override;
|
||||
void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track) override;
|
||||
void OnAddLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) override;
|
||||
uint32_t ssrc) override;
|
||||
void OnAddLocalVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track,
|
||||
uint32 ssrc) override;
|
||||
uint32_t ssrc) override;
|
||||
void OnRemoveLocalAudioTrack(MediaStreamInterface* stream,
|
||||
AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) override;
|
||||
uint32_t ssrc) override;
|
||||
void OnRemoveLocalVideoTrack(MediaStreamInterface* stream,
|
||||
VideoTrackInterface* video_track) override;
|
||||
void OnRemoveLocalStream(MediaStreamInterface* stream) override;
|
||||
|
||||
@ -58,7 +58,7 @@ static const char kTurnIceServerUri[] = "turn:user@turn.example.org";
|
||||
static const char kTurnUsername[] = "user";
|
||||
static const char kTurnPassword[] = "password";
|
||||
static const char kTurnHostname[] = "turn.example.org";
|
||||
static const uint32 kTimeout = 10000U;
|
||||
static const uint32_t kTimeout = 10000U;
|
||||
|
||||
#define MAYBE_SKIP_TEST(feature) \
|
||||
if (!(feature())) { \
|
||||
|
||||
@ -65,7 +65,7 @@ bool RemoteVideoCapturer::IsRunning() {
|
||||
return capture_state() == cricket::CS_RUNNING;
|
||||
}
|
||||
|
||||
bool RemoteVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
|
||||
bool RemoteVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
|
||||
if (!fourccs)
|
||||
return false;
|
||||
fourccs->push_back(cricket::FOURCC_I420);
|
||||
|
||||
@ -51,7 +51,7 @@ class RemoteVideoCapturer : public cricket::VideoCapturer {
|
||||
const cricket::VideoFormat& capture_format) override;
|
||||
void Stop() override;
|
||||
bool IsRunning() override;
|
||||
bool GetPreferredFourccs(std::vector<uint32>* fourccs) override;
|
||||
bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override;
|
||||
bool GetBestCaptureFormat(const cricket::VideoFormat& desired,
|
||||
cricket::VideoFormat* best_format) override;
|
||||
bool IsScreencast() const override;
|
||||
|
||||
@ -104,7 +104,7 @@ TEST_F(RemoteVideoCapturerTest, StartStop) {
|
||||
TEST_F(RemoteVideoCapturerTest, GetPreferredFourccs) {
|
||||
EXPECT_FALSE(capturer_.GetPreferredFourccs(NULL));
|
||||
|
||||
std::vector<uint32> fourccs;
|
||||
std::vector<uint32_t> fourccs;
|
||||
EXPECT_TRUE(capturer_.GetPreferredFourccs(&fourccs));
|
||||
EXPECT_EQ(1u, fourccs.size());
|
||||
EXPECT_EQ(cricket::FOURCC_I420, fourccs.at(0));
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
AudioRtpReceiver::AudioRtpReceiver(AudioTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
AudioProviderInterface* provider)
|
||||
: id_(track->id()),
|
||||
track_(track),
|
||||
@ -82,7 +82,7 @@ void AudioRtpReceiver::Reconfigure() {
|
||||
}
|
||||
|
||||
VideoRtpReceiver::VideoRtpReceiver(VideoTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
VideoProviderInterface* provider)
|
||||
: id_(track->id()), track_(track), ssrc_(ssrc), provider_(provider) {
|
||||
provider_->SetVideoPlayout(ssrc_, true, track_->GetSource()->FrameInput());
|
||||
|
||||
@ -45,7 +45,7 @@ class AudioRtpReceiver : public ObserverInterface,
|
||||
public rtc::RefCountedObject<RtpReceiverInterface> {
|
||||
public:
|
||||
AudioRtpReceiver(AudioTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
AudioProviderInterface* provider);
|
||||
|
||||
virtual ~AudioRtpReceiver();
|
||||
@ -70,7 +70,7 @@ class AudioRtpReceiver : public ObserverInterface,
|
||||
|
||||
std::string id_;
|
||||
rtc::scoped_refptr<AudioTrackInterface> track_;
|
||||
uint32 ssrc_;
|
||||
uint32_t ssrc_;
|
||||
AudioProviderInterface* provider_;
|
||||
bool cached_track_enabled_;
|
||||
};
|
||||
@ -78,7 +78,7 @@ class AudioRtpReceiver : public ObserverInterface,
|
||||
class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> {
|
||||
public:
|
||||
VideoRtpReceiver(VideoTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
VideoProviderInterface* provider);
|
||||
|
||||
virtual ~VideoRtpReceiver();
|
||||
@ -95,7 +95,7 @@ class VideoRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> {
|
||||
private:
|
||||
std::string id_;
|
||||
rtc::scoped_refptr<VideoTrackInterface> track_;
|
||||
uint32 ssrc_;
|
||||
uint32_t ssrc_;
|
||||
VideoProviderInterface* provider_;
|
||||
};
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ void LocalAudioSinkAdapter::SetSink(cricket::AudioRenderer::Sink* sink) {
|
||||
}
|
||||
|
||||
AudioRtpSender::AudioRtpSender(AudioTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
AudioProviderInterface* provider)
|
||||
: id_(track->id()),
|
||||
track_(track),
|
||||
@ -136,7 +136,7 @@ void AudioRtpSender::Reconfigure() {
|
||||
}
|
||||
|
||||
VideoRtpSender::VideoRtpSender(VideoTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
VideoProviderInterface* provider)
|
||||
: id_(track->id()),
|
||||
track_(track),
|
||||
|
||||
@ -71,7 +71,7 @@ class AudioRtpSender : public ObserverInterface,
|
||||
public rtc::RefCountedObject<RtpSenderInterface> {
|
||||
public:
|
||||
AudioRtpSender(AudioTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
AudioProviderInterface* provider);
|
||||
|
||||
virtual ~AudioRtpSender();
|
||||
@ -94,7 +94,7 @@ class AudioRtpSender : public ObserverInterface,
|
||||
|
||||
std::string id_;
|
||||
rtc::scoped_refptr<AudioTrackInterface> track_;
|
||||
uint32 ssrc_;
|
||||
uint32_t ssrc_;
|
||||
AudioProviderInterface* provider_;
|
||||
bool cached_track_enabled_;
|
||||
|
||||
@ -107,7 +107,7 @@ class VideoRtpSender : public ObserverInterface,
|
||||
public rtc::RefCountedObject<RtpSenderInterface> {
|
||||
public:
|
||||
VideoRtpSender(VideoTrackInterface* track,
|
||||
uint32 ssrc,
|
||||
uint32_t ssrc,
|
||||
VideoProviderInterface* provider);
|
||||
|
||||
virtual ~VideoRtpSender();
|
||||
@ -130,7 +130,7 @@ class VideoRtpSender : public ObserverInterface,
|
||||
|
||||
std::string id_;
|
||||
rtc::scoped_refptr<VideoTrackInterface> track_;
|
||||
uint32 ssrc_;
|
||||
uint32_t ssrc_;
|
||||
VideoProviderInterface* provider_;
|
||||
bool cached_track_enabled_;
|
||||
};
|
||||
|
||||
@ -47,8 +47,8 @@ using ::testing::Exactly;
|
||||
static const char kStreamLabel1[] = "local_stream_1";
|
||||
static const char kVideoTrackId[] = "video_1";
|
||||
static const char kAudioTrackId[] = "audio_1";
|
||||
static const uint32 kVideoSsrc = 98;
|
||||
static const uint32 kAudioSsrc = 99;
|
||||
static const uint32_t kVideoSsrc = 98;
|
||||
static const uint32_t kAudioSsrc = 99;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -57,15 +57,15 @@ class MockAudioProvider : public AudioProviderInterface {
|
||||
public:
|
||||
virtual ~MockAudioProvider() {}
|
||||
MOCK_METHOD3(SetAudioPlayout,
|
||||
void(uint32 ssrc,
|
||||
void(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::AudioRenderer* renderer));
|
||||
MOCK_METHOD4(SetAudioSend,
|
||||
void(uint32 ssrc,
|
||||
void(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::AudioOptions& options,
|
||||
cricket::AudioRenderer* renderer));
|
||||
MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32 ssrc, double volume));
|
||||
MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume));
|
||||
};
|
||||
|
||||
// Helper class to test RtpSender/RtpReceiver.
|
||||
@ -73,13 +73,13 @@ class MockVideoProvider : public VideoProviderInterface {
|
||||
public:
|
||||
virtual ~MockVideoProvider() {}
|
||||
MOCK_METHOD2(SetCaptureDevice,
|
||||
bool(uint32 ssrc, cricket::VideoCapturer* camera));
|
||||
bool(uint32_t ssrc, cricket::VideoCapturer* camera));
|
||||
MOCK_METHOD3(SetVideoPlayout,
|
||||
void(uint32 ssrc,
|
||||
void(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::VideoRenderer* renderer));
|
||||
MOCK_METHOD3(SetVideoSend,
|
||||
void(uint32 ssrc,
|
||||
void(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::VideoOptions* options));
|
||||
};
|
||||
|
||||
@ -36,8 +36,8 @@ namespace webrtc {
|
||||
// Format defined at
|
||||
// http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-01#section
|
||||
|
||||
static const uint8 DATA_CHANNEL_OPEN_MESSAGE_TYPE = 0x03;
|
||||
static const uint8 DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE = 0x02;
|
||||
static const uint8_t DATA_CHANNEL_OPEN_MESSAGE_TYPE = 0x03;
|
||||
static const uint8_t DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE = 0x02;
|
||||
|
||||
enum DataChannelOpenMessageChannelType {
|
||||
DCOMCT_ORDERED_RELIABLE = 0x00,
|
||||
@ -55,7 +55,7 @@ bool ParseDataChannelOpenMessage(const rtc::Buffer& payload,
|
||||
// http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04
|
||||
|
||||
rtc::ByteBuffer buffer(payload);
|
||||
uint8 message_type;
|
||||
uint8_t message_type;
|
||||
if (!buffer.ReadUInt8(&message_type)) {
|
||||
LOG(LS_WARNING) << "Could not read OPEN message type.";
|
||||
return false;
|
||||
@ -66,28 +66,28 @@ bool ParseDataChannelOpenMessage(const rtc::Buffer& payload,
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8 channel_type;
|
||||
uint8_t channel_type;
|
||||
if (!buffer.ReadUInt8(&channel_type)) {
|
||||
LOG(LS_WARNING) << "Could not read OPEN message channel type.";
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16 priority;
|
||||
uint16_t priority;
|
||||
if (!buffer.ReadUInt16(&priority)) {
|
||||
LOG(LS_WARNING) << "Could not read OPEN message reliabilility prioirty.";
|
||||
return false;
|
||||
}
|
||||
uint32 reliability_param;
|
||||
uint32_t reliability_param;
|
||||
if (!buffer.ReadUInt32(&reliability_param)) {
|
||||
LOG(LS_WARNING) << "Could not read OPEN message reliabilility param.";
|
||||
return false;
|
||||
}
|
||||
uint16 label_length;
|
||||
uint16_t label_length;
|
||||
if (!buffer.ReadUInt16(&label_length)) {
|
||||
LOG(LS_WARNING) << "Could not read OPEN message label length.";
|
||||
return false;
|
||||
}
|
||||
uint16 protocol_length;
|
||||
uint16_t protocol_length;
|
||||
if (!buffer.ReadUInt16(&protocol_length)) {
|
||||
LOG(LS_WARNING) << "Could not read OPEN message protocol length.";
|
||||
return false;
|
||||
@ -126,7 +126,7 @@ bool ParseDataChannelOpenMessage(const rtc::Buffer& payload,
|
||||
|
||||
bool ParseDataChannelOpenAckMessage(const rtc::Buffer& payload) {
|
||||
rtc::ByteBuffer buffer(payload);
|
||||
uint8 message_type;
|
||||
uint8_t message_type;
|
||||
if (!buffer.ReadUInt8(&message_type)) {
|
||||
LOG(LS_WARNING) << "Could not read OPEN_ACK message type.";
|
||||
return false;
|
||||
@ -144,9 +144,9 @@ bool WriteDataChannelOpenMessage(const std::string& label,
|
||||
rtc::Buffer* payload) {
|
||||
// Format defined at
|
||||
// http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-00#section-6.1
|
||||
uint8 channel_type = 0;
|
||||
uint32 reliability_param = 0;
|
||||
uint16 priority = 0;
|
||||
uint8_t channel_type = 0;
|
||||
uint32_t reliability_param = 0;
|
||||
uint16_t priority = 0;
|
||||
if (config.ordered) {
|
||||
if (config.maxRetransmits > -1) {
|
||||
channel_type = DCOMCT_ORDERED_PARTIAL_RTXS;
|
||||
@ -176,8 +176,8 @@ bool WriteDataChannelOpenMessage(const std::string& label,
|
||||
buffer.WriteUInt8(channel_type);
|
||||
buffer.WriteUInt16(priority);
|
||||
buffer.WriteUInt32(reliability_param);
|
||||
buffer.WriteUInt16(static_cast<uint16>(label.length()));
|
||||
buffer.WriteUInt16(static_cast<uint16>(config.protocol.length()));
|
||||
buffer.WriteUInt16(static_cast<uint16_t>(label.length()));
|
||||
buffer.WriteUInt16(static_cast<uint16_t>(config.protocol.length()));
|
||||
buffer.WriteString(label);
|
||||
buffer.WriteString(config.protocol);
|
||||
payload->SetData(buffer.Data(), buffer.Length());
|
||||
|
||||
@ -34,12 +34,12 @@ class SctpUtilsTest : public testing::Test {
|
||||
void VerifyOpenMessageFormat(const rtc::Buffer& packet,
|
||||
const std::string& label,
|
||||
const webrtc::DataChannelInit& config) {
|
||||
uint8 message_type;
|
||||
uint8 channel_type;
|
||||
uint32 reliability;
|
||||
uint16 priority;
|
||||
uint16 label_length;
|
||||
uint16 protocol_length;
|
||||
uint8_t message_type;
|
||||
uint8_t channel_type;
|
||||
uint32_t reliability;
|
||||
uint16_t priority;
|
||||
uint16_t label_length;
|
||||
uint16_t protocol_length;
|
||||
|
||||
rtc::ByteBuffer buffer(packet.data(), packet.length());
|
||||
ASSERT_TRUE(buffer.ReadUInt8(&message_type));
|
||||
@ -152,7 +152,7 @@ TEST_F(SctpUtilsTest, WriteParseAckMessage) {
|
||||
rtc::Buffer packet;
|
||||
webrtc::WriteDataChannelOpenAckMessage(&packet);
|
||||
|
||||
uint8 message_type;
|
||||
uint8_t message_type;
|
||||
rtc::ByteBuffer buffer(packet.data(), packet.length());
|
||||
ASSERT_TRUE(buffer.ReadUInt8(&message_type));
|
||||
EXPECT_EQ(0x02, message_type);
|
||||
|
||||
@ -66,7 +66,7 @@ struct TypeForAdd {
|
||||
|
||||
typedef TypeForAdd<bool> BoolForAdd;
|
||||
typedef TypeForAdd<float> FloatForAdd;
|
||||
typedef TypeForAdd<int64> Int64ForAdd;
|
||||
typedef TypeForAdd<int64_t> Int64ForAdd;
|
||||
typedef TypeForAdd<int> IntForAdd;
|
||||
|
||||
StatsReport::Id GetTransportIdFromProxy(const cricket::ProxyTransportMap& map,
|
||||
@ -301,7 +301,7 @@ void ExtractStatsFromList(const std::vector<T>& data,
|
||||
StatsCollector* collector,
|
||||
StatsReport::Direction direction) {
|
||||
for (const auto& d : data) {
|
||||
uint32 ssrc = d.ssrc();
|
||||
uint32_t ssrc = d.ssrc();
|
||||
// Each track can have stats for both local and remote objects.
|
||||
// TODO(hta): Handle the case of multiple SSRCs per object.
|
||||
StatsReport* report = collector->PrepareReport(true, ssrc, transport_id,
|
||||
@ -383,7 +383,7 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
||||
}
|
||||
|
||||
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
RTC_DCHECK(audio_track != NULL);
|
||||
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
|
||||
@ -405,7 +405,7 @@ void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
||||
}
|
||||
|
||||
void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
RTC_DCHECK(audio_track != NULL);
|
||||
local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
|
||||
local_audio_tracks_.end(),
|
||||
@ -482,16 +482,15 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
||||
}
|
||||
}
|
||||
|
||||
StatsReport* StatsCollector::PrepareReport(
|
||||
bool local,
|
||||
uint32 ssrc,
|
||||
const StatsReport::Id& transport_id,
|
||||
StatsReport::Direction direction) {
|
||||
StatsReport* StatsCollector::PrepareReport(bool local,
|
||||
uint32_t ssrc,
|
||||
const StatsReport::Id& transport_id,
|
||||
StatsReport::Direction direction) {
|
||||
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
StatsReport::Id id(StatsReport::NewIdWithDirection(
|
||||
local ? StatsReport::kStatsReportTypeSsrc :
|
||||
StatsReport::kStatsReportTypeRemoteSsrc,
|
||||
rtc::ToString<uint32>(ssrc), direction));
|
||||
local ? StatsReport::kStatsReportTypeSsrc
|
||||
: StatsReport::kStatsReportTypeRemoteSsrc,
|
||||
rtc::ToString<uint32_t>(ssrc), direction));
|
||||
StatsReport* report = reports_.Find(id);
|
||||
|
||||
// Use the ID of the track that is currently mapped to the SSRC, if any.
|
||||
@ -861,10 +860,10 @@ void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
||||
// Loop through the existing local audio tracks.
|
||||
for (const auto& it : local_audio_tracks_) {
|
||||
AudioTrackInterface* track = it.first;
|
||||
uint32 ssrc = it.second;
|
||||
StatsReport* report = GetReport(StatsReport::kStatsReportTypeSsrc,
|
||||
rtc::ToString<uint32>(ssrc),
|
||||
StatsReport::kSend);
|
||||
uint32_t ssrc = it.second;
|
||||
StatsReport* report =
|
||||
GetReport(StatsReport::kStatsReportTypeSsrc,
|
||||
rtc::ToString<uint32_t>(ssrc), StatsReport::kSend);
|
||||
if (report == NULL) {
|
||||
// This can happen if a local audio track is added to a stream on the
|
||||
// fly and the report has not been set up yet. Do nothing in this case.
|
||||
@ -905,7 +904,8 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
||||
stats.echo_delay_std_ms);
|
||||
}
|
||||
|
||||
bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
||||
bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
|
||||
std::string* track_id,
|
||||
StatsReport::Direction direction) {
|
||||
RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
if (direction == StatsReport::kSend) {
|
||||
|
||||
@ -67,11 +67,11 @@ class StatsCollector {
|
||||
void AddStream(MediaStreamInterface* stream);
|
||||
|
||||
// Adds a local audio track that is used for getting some voice statistics.
|
||||
void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc);
|
||||
void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc);
|
||||
|
||||
// Removes a local audio tracks that is used for getting some voice
|
||||
// statistics.
|
||||
void RemoveLocalAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc);
|
||||
void RemoveLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc);
|
||||
|
||||
// Gather statistics from the session and store them for future use.
|
||||
void UpdateStats(PeerConnectionInterface::StatsOutputLevel level);
|
||||
@ -89,8 +89,10 @@ class StatsCollector {
|
||||
|
||||
// Prepare a local or remote SSRC report for the given ssrc. Used internally
|
||||
// in the ExtractStatsFromList template.
|
||||
StatsReport* PrepareReport(bool local, uint32 ssrc,
|
||||
const StatsReport::Id& transport_id, StatsReport::Direction direction);
|
||||
StatsReport* PrepareReport(bool local,
|
||||
uint32_t ssrc,
|
||||
const StatsReport::Id& transport_id,
|
||||
StatsReport::Direction direction);
|
||||
|
||||
// Method used by the unittest to force a update of stats since UpdateStats()
|
||||
// that occur less than kMinGatherStatsPeriod number of ms apart will be
|
||||
@ -139,7 +141,8 @@ class StatsCollector {
|
||||
|
||||
// Helper method to get the id for the track identified by ssrc.
|
||||
// |direction| tells if the track is for sending or receiving.
|
||||
bool GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
||||
bool GetTrackIdBySsrc(uint32_t ssrc,
|
||||
std::string* track_id,
|
||||
StatsReport::Direction direction);
|
||||
|
||||
// Helper method to update the timestamp of track records.
|
||||
@ -155,7 +158,7 @@ class StatsCollector {
|
||||
|
||||
// TODO(tommi): We appear to be holding on to raw pointers to reference
|
||||
// counted objects? We should be using scoped_refptr here.
|
||||
typedef std::vector<std::pair<AudioTrackInterface*, uint32> >
|
||||
typedef std::vector<std::pair<AudioTrackInterface*, uint32_t> >
|
||||
LocalAudioTrackVector;
|
||||
LocalAudioTrackVector local_audio_tracks_;
|
||||
};
|
||||
|
||||
@ -78,7 +78,7 @@ const char kNotFound[] = "NOT FOUND";
|
||||
// Constant names for track identification.
|
||||
const char kLocalTrackId[] = "local_track_id";
|
||||
const char kRemoteTrackId[] = "remote_track_id";
|
||||
const uint32 kSsrcOfTrack = 1234;
|
||||
const uint32_t kSsrcOfTrack = 1234;
|
||||
|
||||
class MockWebRtcSession : public webrtc::WebRtcSession {
|
||||
public:
|
||||
@ -91,8 +91,8 @@ class MockWebRtcSession : public webrtc::WebRtcSession {
|
||||
MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*());
|
||||
// Libjingle uses "local" for a outgoing track, and "remote" for a incoming
|
||||
// track.
|
||||
MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32, std::string*));
|
||||
MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32, std::string*));
|
||||
MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*));
|
||||
MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*));
|
||||
MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*));
|
||||
MOCK_METHOD2(GetLocalCertificate,
|
||||
bool(const std::string& transport_name,
|
||||
@ -301,7 +301,7 @@ void VerifyVoiceReceiverInfoReport(
|
||||
EXPECT_EQ(rtc::ToString<int>(info.audio_level), value_in_report);
|
||||
EXPECT_TRUE(GetValue(
|
||||
report, StatsReport::kStatsValueNameBytesReceived, &value_in_report));
|
||||
EXPECT_EQ(rtc::ToString<int64>(info.bytes_rcvd), value_in_report);
|
||||
EXPECT_EQ(rtc::ToString<int64_t>(info.bytes_rcvd), value_in_report);
|
||||
EXPECT_TRUE(GetValue(
|
||||
report, StatsReport::kStatsValueNameJitterReceived, &value_in_report));
|
||||
EXPECT_EQ(rtc::ToString<int>(info.jitter_ms), value_in_report);
|
||||
@ -367,7 +367,7 @@ void VerifyVoiceSenderInfoReport(const StatsReport* report,
|
||||
EXPECT_EQ(sinfo.codec_name, value_in_report);
|
||||
EXPECT_TRUE(GetValue(
|
||||
report, StatsReport::kStatsValueNameBytesSent, &value_in_report));
|
||||
EXPECT_EQ(rtc::ToString<int64>(sinfo.bytes_sent), value_in_report);
|
||||
EXPECT_EQ(rtc::ToString<int64_t>(sinfo.bytes_sent), value_in_report);
|
||||
EXPECT_TRUE(GetValue(
|
||||
report, StatsReport::kStatsValueNamePacketsSent, &value_in_report));
|
||||
EXPECT_EQ(rtc::ToString<int>(sinfo.packets_sent), value_in_report);
|
||||
@ -610,7 +610,7 @@ class StatsCollectorTest : public testing::Test {
|
||||
EXPECT_EQ(audio_track->id(), track_id);
|
||||
std::string ssrc_id = ExtractSsrcStatsValue(
|
||||
*reports, StatsReport::kStatsValueNameSsrc);
|
||||
EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
|
||||
EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
|
||||
|
||||
// Verifies the values in the track report.
|
||||
if (voice_sender_info) {
|
||||
@ -633,7 +633,7 @@ class StatsCollectorTest : public testing::Test {
|
||||
EXPECT_EQ(audio_track->id(), track_id);
|
||||
ssrc_id = ExtractSsrcStatsValue(track_reports,
|
||||
StatsReport::kStatsValueNameSsrc);
|
||||
EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
|
||||
EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
|
||||
if (voice_sender_info)
|
||||
VerifyVoiceSenderInfoReport(track_report, *voice_sender_info);
|
||||
if (voice_receiver_info)
|
||||
@ -775,9 +775,8 @@ TEST_F(StatsCollectorTest, ExtractDataInfo) {
|
||||
EXPECT_EQ(label, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel,
|
||||
reports,
|
||||
StatsReport::kStatsValueNameLabel));
|
||||
EXPECT_EQ(rtc::ToString<int64>(id),
|
||||
ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel,
|
||||
reports,
|
||||
EXPECT_EQ(rtc::ToString<int64_t>(id),
|
||||
ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, reports,
|
||||
StatsReport::kStatsValueNameDataChannelId));
|
||||
EXPECT_EQ(state, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel,
|
||||
reports,
|
||||
@ -810,7 +809,7 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
|
||||
cricket::VideoSenderInfo video_sender_info;
|
||||
cricket::VideoMediaInfo stats_read;
|
||||
// The number of bytes must be larger than 0xFFFFFFFF for this test.
|
||||
const int64 kBytesSent = 12345678901234LL;
|
||||
const int64_t kBytesSent = 12345678901234LL;
|
||||
const std::string kBytesSentString("12345678901234");
|
||||
|
||||
AddOutgoingVideoTrackStats();
|
||||
@ -858,7 +857,7 @@ TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
|
||||
cricket::VideoMediaInfo stats_read;
|
||||
// Set up an SSRC just to test that we get both kinds of stats back: SSRC and
|
||||
// BWE.
|
||||
const int64 kBytesSent = 12345678901234LL;
|
||||
const int64_t kBytesSent = 12345678901234LL;
|
||||
const std::string kBytesSentString("12345678901234");
|
||||
|
||||
AddOutgoingVideoTrackStats();
|
||||
@ -973,7 +972,7 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
|
||||
// Constructs an ssrc stats update.
|
||||
cricket::VideoSenderInfo video_sender_info;
|
||||
cricket::VideoMediaInfo stats_read;
|
||||
const int64 kBytesSent = 12345678901234LL;
|
||||
const int64_t kBytesSent = 12345678901234LL;
|
||||
|
||||
// Construct a stats value to read.
|
||||
video_sender_info.add_ssrc(1234);
|
||||
@ -1009,7 +1008,7 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) {
|
||||
|
||||
std::string ssrc_id = ExtractSsrcStatsValue(
|
||||
reports, StatsReport::kStatsValueNameSsrc);
|
||||
EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
|
||||
EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
|
||||
|
||||
std::string track_id = ExtractSsrcStatsValue(
|
||||
reports, StatsReport::kStatsValueNameTrackId);
|
||||
@ -1037,7 +1036,7 @@ TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) {
|
||||
// Constructs an ssrc stats update.
|
||||
cricket::VideoSenderInfo video_sender_info;
|
||||
cricket::VideoMediaInfo stats_read;
|
||||
const int64 kBytesSent = 12345678901234LL;
|
||||
const int64_t kBytesSent = 12345678901234LL;
|
||||
|
||||
// Construct a stats value to read.
|
||||
video_sender_info.add_ssrc(1234);
|
||||
@ -1179,7 +1178,7 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) {
|
||||
// Constructs an ssrc stats update.
|
||||
cricket::VideoReceiverInfo video_receiver_info;
|
||||
cricket::VideoMediaInfo stats_read;
|
||||
const int64 kNumOfPacketsConcealed = 54321;
|
||||
const int64_t kNumOfPacketsConcealed = 54321;
|
||||
|
||||
// Construct a stats value to read.
|
||||
video_receiver_info.add_ssrc(1234);
|
||||
@ -1205,7 +1204,7 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) {
|
||||
|
||||
std::string ssrc_id = ExtractSsrcStatsValue(
|
||||
reports, StatsReport::kStatsValueNameSsrc);
|
||||
EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
|
||||
EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
|
||||
|
||||
std::string track_id = ExtractSsrcStatsValue(
|
||||
reports, StatsReport::kStatsValueNameTrackId);
|
||||
@ -1227,7 +1226,7 @@ TEST_F(StatsCollectorTest, IceCandidateReport) {
|
||||
rtc::SocketAddress local_address(local_ip, local_port);
|
||||
rtc::SocketAddress remote_address(remote_ip, remote_port);
|
||||
rtc::AdapterType network_type = rtc::ADAPTER_TYPE_ETHERNET;
|
||||
uint32 priority = 1000;
|
||||
uint32_t priority = 1000;
|
||||
|
||||
cricket::Candidate c;
|
||||
ASSERT(c.id().length() > 0);
|
||||
@ -1590,7 +1589,7 @@ TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) {
|
||||
EXPECT_EQ(kLocalTrackId, track_id);
|
||||
std::string ssrc_id = ExtractSsrcStatsValue(
|
||||
reports, StatsReport::kStatsValueNameSsrc);
|
||||
EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
|
||||
EXPECT_EQ(rtc::ToString<uint32_t>(kSsrcOfTrack), ssrc_id);
|
||||
|
||||
// Verifies the values in the track report, no value will be changed by the
|
||||
// AudioTrackInterface::GetSignalValue() and
|
||||
|
||||
@ -229,7 +229,7 @@ bool StatsReport::IdBase::Equals(const IdBase& other) const {
|
||||
return other.type_ == type_;
|
||||
}
|
||||
|
||||
StatsReport::Value::Value(StatsValueName name, int64 value, Type int_type)
|
||||
StatsReport::Value::Value(StatsValueName name, int64_t value, Type int_type)
|
||||
: name(name), type_(int_type) {
|
||||
RTC_DCHECK(type_ == kInt || type_ == kInt64);
|
||||
type_ == kInt ? value_.int_ = static_cast<int>(value) : value_.int64_ = value;
|
||||
@ -331,7 +331,7 @@ bool StatsReport::Value::operator==(const char* value) const {
|
||||
return value == value_.static_string_;
|
||||
}
|
||||
|
||||
bool StatsReport::Value::operator==(int64 value) const {
|
||||
bool StatsReport::Value::operator==(int64_t value) const {
|
||||
return type_ == kInt ? value_.int_ == static_cast<int>(value) :
|
||||
(type_ == kInt64 ? value_.int64_ == value : false);
|
||||
}
|
||||
@ -353,7 +353,7 @@ int StatsReport::Value::int_val() const {
|
||||
return value_.int_;
|
||||
}
|
||||
|
||||
int64 StatsReport::Value::int64_val() const {
|
||||
int64_t StatsReport::Value::int64_val() const {
|
||||
RTC_DCHECK(type_ == kInt64);
|
||||
return value_.int64_;
|
||||
}
|
||||
@ -682,7 +682,7 @@ void StatsReport::AddString(StatsReport::StatsValueName name,
|
||||
values_[name] = ValuePtr(new Value(name, value));
|
||||
}
|
||||
|
||||
void StatsReport::AddInt64(StatsReport::StatsValueName name, int64 value) {
|
||||
void StatsReport::AddInt64(StatsReport::StatsValueName name, int64_t value) {
|
||||
const Value* found = FindValue(name);
|
||||
if (!found || !(*found == value))
|
||||
values_[name] = ValuePtr(new Value(name, value, Value::kInt64));
|
||||
@ -690,7 +690,7 @@ void StatsReport::AddInt64(StatsReport::StatsValueName name, int64 value) {
|
||||
|
||||
void StatsReport::AddInt(StatsReport::StatsValueName name, int value) {
|
||||
const Value* found = FindValue(name);
|
||||
if (!found || !(*found == static_cast<int64>(value)))
|
||||
if (!found || !(*found == static_cast<int64_t>(value)))
|
||||
values_[name] = ValuePtr(new Value(name, value, Value::kInt));
|
||||
}
|
||||
|
||||
|
||||
@ -250,16 +250,16 @@ class StatsReport {
|
||||
|
||||
struct Value {
|
||||
enum Type {
|
||||
kInt, // int.
|
||||
kInt64, // int64.
|
||||
kFloat, // float.
|
||||
kString, // std::string
|
||||
kInt, // int.
|
||||
kInt64, // int64_t.
|
||||
kFloat, // float.
|
||||
kString, // std::string
|
||||
kStaticString, // const char*.
|
||||
kBool, // bool.
|
||||
kId, // Id.
|
||||
kBool, // bool.
|
||||
kId, // Id.
|
||||
};
|
||||
|
||||
Value(StatsValueName name, int64 value, Type int_type);
|
||||
Value(StatsValueName name, int64_t value, Type int_type);
|
||||
Value(StatsValueName name, float f);
|
||||
Value(StatsValueName name, const std::string& value);
|
||||
Value(StatsValueName name, const char* value);
|
||||
@ -281,7 +281,7 @@ class StatsReport {
|
||||
// kString and kStaticString too.
|
||||
bool operator==(const std::string& value) const;
|
||||
bool operator==(const char* value) const;
|
||||
bool operator==(int64 value) const;
|
||||
bool operator==(int64_t value) const;
|
||||
bool operator==(bool value) const;
|
||||
bool operator==(float value) const;
|
||||
bool operator==(const Id& value) const;
|
||||
@ -289,7 +289,7 @@ class StatsReport {
|
||||
// Getters that allow getting the native value directly.
|
||||
// The caller must know the type beforehand or else hit a check.
|
||||
int int_val() const;
|
||||
int64 int64_val() const;
|
||||
int64_t int64_val() const;
|
||||
float float_val() const;
|
||||
const char* static_string_val() const;
|
||||
const std::string& string_val() const;
|
||||
@ -312,7 +312,7 @@ class StatsReport {
|
||||
// TODO(tommi): Use C++ 11 union and make value_ const.
|
||||
union InternalType {
|
||||
int int_;
|
||||
int64 int64_;
|
||||
int64_t int64_;
|
||||
float float_;
|
||||
bool bool_;
|
||||
std::string* string_;
|
||||
@ -355,7 +355,7 @@ class StatsReport {
|
||||
|
||||
void AddString(StatsValueName name, const std::string& value);
|
||||
void AddString(StatsValueName name, const char* value);
|
||||
void AddInt64(StatsValueName name, int64 value);
|
||||
void AddInt64(StatsValueName name, int64_t value);
|
||||
void AddInt(StatsValueName name, int value);
|
||||
void AddFloat(StatsValueName name, float value);
|
||||
void AddBoolean(StatsValueName name, bool value);
|
||||
|
||||
@ -40,7 +40,7 @@ static const int kHighSampleValue = 10000;
|
||||
|
||||
// Same value as src/modules/audio_device/main/source/audio_device_config.h in
|
||||
// https://code.google.com/p/webrtc/
|
||||
static const uint32 kAdmMaxIdleTimeProcess = 1000;
|
||||
static const uint32_t kAdmMaxIdleTimeProcess = 1000;
|
||||
|
||||
// Constants here are derived by running VoE using a real ADM.
|
||||
// The constants correspond to 10ms of mono audio at 44kHz.
|
||||
@ -90,12 +90,12 @@ int FakeAudioCaptureModule::frames_received() const {
|
||||
}
|
||||
|
||||
int64_t FakeAudioCaptureModule::TimeUntilNextProcess() {
|
||||
const uint32 current_time = rtc::Time();
|
||||
const uint32_t current_time = rtc::Time();
|
||||
if (current_time < last_process_time_ms_) {
|
||||
// TODO: wraparound could be handled more gracefully.
|
||||
return 0;
|
||||
}
|
||||
const uint32 elapsed_time = current_time - last_process_time_ms_;
|
||||
const uint32_t elapsed_time = current_time - last_process_time_ms_;
|
||||
if (kAdmMaxIdleTimeProcess < elapsed_time) {
|
||||
return 0;
|
||||
}
|
||||
@ -684,9 +684,9 @@ void FakeAudioCaptureModule::ProcessFrameP() {
|
||||
}
|
||||
|
||||
next_frame_time_ += kTimePerFrameMs;
|
||||
const uint32 current_time = rtc::Time();
|
||||
const uint32 wait_time = (next_frame_time_ > current_time) ?
|
||||
next_frame_time_ - current_time : 0;
|
||||
const uint32_t current_time = rtc::Time();
|
||||
const uint32_t wait_time =
|
||||
(next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0;
|
||||
process_thread_->PostDelayed(wait_time, this, MSG_RUN_PROCESS);
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ class FakeAudioCaptureModule
|
||||
: public webrtc::AudioDeviceModule,
|
||||
public rtc::MessageHandler {
|
||||
public:
|
||||
typedef uint16 Sample;
|
||||
typedef uint16_t Sample;
|
||||
|
||||
// The value for the following constants have been derived by running VoE
|
||||
// using a real ADM. The constants correspond to 10ms of mono audio at 44kHz.
|
||||
@ -242,7 +242,7 @@ class FakeAudioCaptureModule
|
||||
|
||||
// The time in milliseconds when Process() was last called or 0 if no call
|
||||
// has been made.
|
||||
uint32 last_process_time_ms_;
|
||||
uint32_t last_process_time_ms_;
|
||||
|
||||
// Callback for playout and recording.
|
||||
webrtc::AudioTransport* audio_callback_;
|
||||
@ -262,7 +262,7 @@ class FakeAudioCaptureModule
|
||||
// wall clock time the next frame should be generated and received. started_
|
||||
// ensures that next_frame_time_ can be initialized properly on first call.
|
||||
bool started_;
|
||||
uint32 next_frame_time_;
|
||||
uint32_t next_frame_time_;
|
||||
|
||||
rtc::scoped_ptr<rtc::Thread> process_thread_;
|
||||
|
||||
|
||||
@ -137,11 +137,11 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
|
||||
return connected_channels_.find(data_channel) != connected_channels_.end();
|
||||
}
|
||||
|
||||
bool IsSendStreamAdded(uint32 stream) const {
|
||||
bool IsSendStreamAdded(uint32_t stream) const {
|
||||
return send_ssrcs_.find(stream) != send_ssrcs_.end();
|
||||
}
|
||||
|
||||
bool IsRecvStreamAdded(uint32 stream) const {
|
||||
bool IsRecvStreamAdded(uint32_t stream) const {
|
||||
return recv_ssrcs_.find(stream) != recv_ssrcs_.end();
|
||||
}
|
||||
|
||||
@ -152,6 +152,6 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
|
||||
bool ready_to_send_;
|
||||
bool transport_error_;
|
||||
std::set<webrtc::DataChannel*> connected_channels_;
|
||||
std::set<uint32> send_ssrcs_;
|
||||
std::set<uint32> recv_ssrcs_;
|
||||
std::set<uint32_t> send_ssrcs_;
|
||||
std::set<uint32_t> recv_ssrcs_;
|
||||
};
|
||||
|
||||
@ -90,16 +90,16 @@ class FakeMediaStreamSignaling : public webrtc::MediaStreamSignaling,
|
||||
virtual void OnAddDataChannel(webrtc::DataChannelInterface* data_channel) {}
|
||||
virtual void OnAddLocalAudioTrack(webrtc::MediaStreamInterface* stream,
|
||||
webrtc::AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {}
|
||||
uint32_t ssrc) {}
|
||||
virtual void OnAddLocalVideoTrack(webrtc::MediaStreamInterface* stream,
|
||||
webrtc::VideoTrackInterface* video_track,
|
||||
uint32 ssrc) {}
|
||||
uint32_t ssrc) {}
|
||||
virtual void OnAddRemoteAudioTrack(webrtc::MediaStreamInterface* stream,
|
||||
webrtc::AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {}
|
||||
uint32_t ssrc) {}
|
||||
virtual void OnAddRemoteVideoTrack(webrtc::MediaStreamInterface* stream,
|
||||
webrtc::VideoTrackInterface* video_track,
|
||||
uint32 ssrc) {}
|
||||
uint32_t ssrc) {}
|
||||
virtual void OnRemoveRemoteAudioTrack(
|
||||
webrtc::MediaStreamInterface* stream,
|
||||
webrtc::AudioTrackInterface* audio_track) {}
|
||||
@ -108,7 +108,7 @@ class FakeMediaStreamSignaling : public webrtc::MediaStreamSignaling,
|
||||
webrtc::VideoTrackInterface* video_track) {}
|
||||
virtual void OnRemoveLocalAudioTrack(webrtc::MediaStreamInterface* stream,
|
||||
webrtc::AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {}
|
||||
uint32_t ssrc) {}
|
||||
virtual void OnRemoveLocalVideoTrack(
|
||||
webrtc::MediaStreamInterface* stream,
|
||||
webrtc::VideoTrackInterface* video_track) {}
|
||||
|
||||
@ -98,7 +98,7 @@ class MockDataChannelObserver : public webrtc::DataChannelObserver {
|
||||
channel_->UnregisterObserver();
|
||||
}
|
||||
|
||||
void OnBufferedAmountChange(uint64 previous_amount) override {}
|
||||
void OnBufferedAmountChange(uint64_t previous_amount) override {}
|
||||
|
||||
void OnStateChange() override { state_ = channel_->state(); }
|
||||
void OnMessage(const DataBuffer& buffer) override {
|
||||
|
||||
@ -250,10 +250,10 @@ const cricket::VideoFormat& GetBestCaptureFormat(
|
||||
std::vector<cricket::VideoFormat>::const_iterator it = formats.begin();
|
||||
std::vector<cricket::VideoFormat>::const_iterator best_it = formats.begin();
|
||||
int best_diff_area = std::abs(default_area - it->width * it->height);
|
||||
int64 best_diff_interval = kDefaultFormat.interval;
|
||||
int64_t best_diff_interval = kDefaultFormat.interval;
|
||||
for (; it != formats.end(); ++it) {
|
||||
int diff_area = std::abs(default_area - it->width * it->height);
|
||||
int64 diff_interval = std::abs(kDefaultFormat.interval - it->interval);
|
||||
int64_t diff_interval = std::abs(kDefaultFormat.interval - it->interval);
|
||||
if (diff_area < best_diff_area ||
|
||||
(diff_area == best_diff_area && diff_interval < best_diff_interval)) {
|
||||
best_diff_area = diff_area;
|
||||
|
||||
@ -231,7 +231,7 @@ struct SsrcInfo {
|
||||
// Create random string (which will be used as track label later)?
|
||||
msid_appdata(rtc::CreateRandomString(8)) {
|
||||
}
|
||||
uint32 ssrc_id;
|
||||
uint32_t ssrc_id;
|
||||
std::string cname;
|
||||
std::string msid_identifier;
|
||||
std::string msid_appdata;
|
||||
@ -525,8 +525,10 @@ static bool HasAttribute(const std::string& line,
|
||||
return (line.compare(kLinePrefixLength, attribute.size(), attribute) == 0);
|
||||
}
|
||||
|
||||
static bool AddSsrcLine(uint32 ssrc_id, const std::string& attribute,
|
||||
const std::string& value, std::string* message) {
|
||||
static bool AddSsrcLine(uint32_t ssrc_id,
|
||||
const std::string& attribute,
|
||||
const std::string& value,
|
||||
std::string* message) {
|
||||
// RFC 5576
|
||||
// a=ssrc:<ssrc-id> <attribute>:<value>
|
||||
std::ostringstream os;
|
||||
@ -1004,7 +1006,7 @@ bool ParseCandidate(const std::string& message, Candidate* candidate,
|
||||
return false;
|
||||
}
|
||||
const std::string& transport = fields[2];
|
||||
uint32 priority = 0;
|
||||
uint32_t priority = 0;
|
||||
if (!GetValueFromString(first_line, fields[3], &priority, error)) {
|
||||
return false;
|
||||
}
|
||||
@ -1078,7 +1080,7 @@ bool ParseCandidate(const std::string& message, Candidate* candidate,
|
||||
// kept for backwards compatibility.
|
||||
std::string username;
|
||||
std::string password;
|
||||
uint32 generation = 0;
|
||||
uint32_t generation = 0;
|
||||
for (size_t i = current_position; i + 1 < fields.size(); ++i) {
|
||||
// RFC 5245
|
||||
// *(SP extension-att-name SP extension-att-value)
|
||||
@ -1441,16 +1443,16 @@ void BuildRtpContentAttributes(
|
||||
std::ostringstream os;
|
||||
InitAttrLine(kAttributeSsrcGroup, &os);
|
||||
os << kSdpDelimiterColon << track->ssrc_groups[i].semantics;
|
||||
std::vector<uint32>::const_iterator ssrc =
|
||||
std::vector<uint32_t>::const_iterator ssrc =
|
||||
track->ssrc_groups[i].ssrcs.begin();
|
||||
for (; ssrc != track->ssrc_groups[i].ssrcs.end(); ++ssrc) {
|
||||
os << kSdpDelimiterSpace << rtc::ToString<uint32>(*ssrc);
|
||||
os << kSdpDelimiterSpace << rtc::ToString<uint32_t>(*ssrc);
|
||||
}
|
||||
AddLine(os.str(), message);
|
||||
}
|
||||
// Build the ssrc lines for each ssrc.
|
||||
for (size_t i = 0; i < track->ssrcs.size(); ++i) {
|
||||
uint32 ssrc = track->ssrcs[i];
|
||||
uint32_t ssrc = track->ssrcs[i];
|
||||
// RFC 5576
|
||||
// a=ssrc:<ssrc-id> cname:<value>
|
||||
AddSsrcLine(ssrc, kSsrcAttributeCname,
|
||||
@ -2634,7 +2636,7 @@ bool ParseContent(const std::string& message,
|
||||
if (ssrc_group->ssrcs.empty()) {
|
||||
continue;
|
||||
}
|
||||
uint32 ssrc = ssrc_group->ssrcs.front();
|
||||
uint32_t ssrc = ssrc_group->ssrcs.front();
|
||||
for (StreamParamsVec::iterator track = tracks.begin();
|
||||
track != tracks.end(); ++track) {
|
||||
if (track->has_ssrc(ssrc)) {
|
||||
@ -2706,7 +2708,7 @@ bool ParseSsrcAttribute(const std::string& line, SsrcInfoVec* ssrc_infos,
|
||||
if (!GetValue(field1, kAttributeSsrc, &ssrc_id_s, error)) {
|
||||
return false;
|
||||
}
|
||||
uint32 ssrc_id = 0;
|
||||
uint32_t ssrc_id = 0;
|
||||
if (!GetValueFromString(line, ssrc_id_s, &ssrc_id, error)) {
|
||||
return false;
|
||||
}
|
||||
@ -2783,9 +2785,9 @@ bool ParseSsrcGroupAttribute(const std::string& line,
|
||||
if (!GetValue(fields[0], kAttributeSsrcGroup, &semantics, error)) {
|
||||
return false;
|
||||
}
|
||||
std::vector<uint32> ssrcs;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
for (size_t i = 1; i < fields.size(); ++i) {
|
||||
uint32 ssrc = 0;
|
||||
uint32_t ssrc = 0;
|
||||
if (!GetValueFromString(line, fields[i], &ssrc, error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -75,9 +75,9 @@ using webrtc::SessionDescriptionInterface;
|
||||
typedef std::vector<AudioCodec> AudioCodecs;
|
||||
typedef std::vector<Candidate> Candidates;
|
||||
|
||||
static const uint32 kDefaultSctpPort = 5000;
|
||||
static const uint32_t kDefaultSctpPort = 5000;
|
||||
static const char kSessionTime[] = "t=0 0\r\n";
|
||||
static const uint32 kCandidatePriority = 2130706432U; // pref = 1.0
|
||||
static const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0
|
||||
static const char kCandidateUfragVoice[] = "ufrag_voice";
|
||||
static const char kCandidatePwdVoice[] = "pwd_voice";
|
||||
static const char kAttributeIcePwdVoice[] = "a=ice-pwd:pwd_voice\r\n";
|
||||
@ -86,7 +86,7 @@ static const char kCandidatePwdVideo[] = "pwd_video";
|
||||
static const char kCandidateUfragData[] = "ufrag_data";
|
||||
static const char kCandidatePwdData[] = "pwd_data";
|
||||
static const char kAttributeIcePwdVideo[] = "a=ice-pwd:pwd_video\r\n";
|
||||
static const uint32 kCandidateGeneration = 2;
|
||||
static const uint32_t kCandidateGeneration = 2;
|
||||
static const char kCandidateFoundation1[] = "a0+B/1";
|
||||
static const char kCandidateFoundation2[] = "a0+B/2";
|
||||
static const char kCandidateFoundation3[] = "a0+B/3";
|
||||
@ -107,11 +107,9 @@ static const char kExtmap[] =
|
||||
static const char kExtmapWithDirectionAndAttribute[] =
|
||||
"a=extmap:1/sendrecv http://example.com/082005/ext.htm#ttime a1 a2\r\n";
|
||||
|
||||
static const uint8 kIdentityDigest[] = {0x4A, 0xAD, 0xB9, 0xB1,
|
||||
0x3F, 0x82, 0x18, 0x3B,
|
||||
0x54, 0x02, 0x12, 0xDF,
|
||||
0x3E, 0x5D, 0x49, 0x6B,
|
||||
0x19, 0xE5, 0x7C, 0xAB};
|
||||
static const uint8_t kIdentityDigest[] = {
|
||||
0x4A, 0xAD, 0xB9, 0xB1, 0x3F, 0x82, 0x18, 0x3B, 0x54, 0x02,
|
||||
0x12, 0xDF, 0x3E, 0x5D, 0x49, 0x6B, 0x19, 0xE5, 0x7C, 0xAB};
|
||||
|
||||
static const char kDtlsSctp[] = "DTLS/SCTP";
|
||||
static const char kUdpDtlsSctp[] = "UDP/DTLS/SCTP";
|
||||
@ -409,26 +407,26 @@ static const char kDataContentName[] = "data_content_name";
|
||||
static const char kStreamLabel1[] = "local_stream_1";
|
||||
static const char kStream1Cname[] = "stream_1_cname";
|
||||
static const char kAudioTrackId1[] = "audio_track_id_1";
|
||||
static const uint32 kAudioTrack1Ssrc = 1;
|
||||
static const uint32_t kAudioTrack1Ssrc = 1;
|
||||
static const char kVideoTrackId1[] = "video_track_id_1";
|
||||
static const uint32 kVideoTrack1Ssrc = 2;
|
||||
static const uint32_t kVideoTrack1Ssrc = 2;
|
||||
static const char kVideoTrackId2[] = "video_track_id_2";
|
||||
static const uint32 kVideoTrack2Ssrc = 3;
|
||||
static const uint32_t kVideoTrack2Ssrc = 3;
|
||||
|
||||
// MediaStream 2
|
||||
static const char kStreamLabel2[] = "local_stream_2";
|
||||
static const char kStream2Cname[] = "stream_2_cname";
|
||||
static const char kAudioTrackId2[] = "audio_track_id_2";
|
||||
static const uint32 kAudioTrack2Ssrc = 4;
|
||||
static const uint32_t kAudioTrack2Ssrc = 4;
|
||||
static const char kVideoTrackId3[] = "video_track_id_3";
|
||||
static const uint32 kVideoTrack3Ssrc = 5;
|
||||
static const uint32 kVideoTrack4Ssrc = 6;
|
||||
static const uint32_t kVideoTrack3Ssrc = 5;
|
||||
static const uint32_t kVideoTrack4Ssrc = 6;
|
||||
|
||||
// DataChannel
|
||||
static const char kDataChannelLabel[] = "data_channel";
|
||||
static const char kDataChannelMsid[] = "data_channeld0";
|
||||
static const char kDataChannelCname[] = "data_channel_cname";
|
||||
static const uint32 kDataChannelSsrc = 10;
|
||||
static const uint32_t kDataChannelSsrc = 10;
|
||||
|
||||
// Candidate
|
||||
static const char kDummyMid[] = "dummy_mid";
|
||||
@ -2157,7 +2155,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithCorruptedSctpDataChannels) {
|
||||
|
||||
TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelAndNewPort) {
|
||||
AddSctpDataChannel();
|
||||
const uint16 kUnusualSctpPort = 9556;
|
||||
const uint16_t kUnusualSctpPort = 9556;
|
||||
char default_portstr[16];
|
||||
char unusual_portstr[16];
|
||||
rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d",
|
||||
|
||||
@ -265,9 +265,9 @@ static void UpdateSessionDescriptionSecurePolicy(cricket::CryptoType type,
|
||||
}
|
||||
}
|
||||
|
||||
static bool GetAudioSsrcByTrackId(
|
||||
const SessionDescription* session_description,
|
||||
const std::string& track_id, uint32 *ssrc) {
|
||||
static bool GetAudioSsrcByTrackId(const SessionDescription* session_description,
|
||||
const std::string& track_id,
|
||||
uint32_t* ssrc) {
|
||||
const cricket::ContentInfo* audio_info =
|
||||
cricket::GetFirstAudioContent(session_description);
|
||||
if (!audio_info) {
|
||||
@ -289,7 +289,8 @@ static bool GetAudioSsrcByTrackId(
|
||||
}
|
||||
|
||||
static bool GetTrackIdBySsrc(const SessionDescription* session_description,
|
||||
uint32 ssrc, std::string* track_id) {
|
||||
uint32_t ssrc,
|
||||
std::string* track_id) {
|
||||
ASSERT(track_id != NULL);
|
||||
|
||||
const cricket::ContentInfo* audio_info =
|
||||
@ -461,7 +462,7 @@ static void SetOptionFromOptionalConstraint(
|
||||
}
|
||||
}
|
||||
|
||||
uint32 ConvertIceTransportTypeToCandidateFilter(
|
||||
uint32_t ConvertIceTransportTypeToCandidateFilter(
|
||||
PeerConnectionInterface::IceTransportsType type) {
|
||||
switch (type) {
|
||||
case PeerConnectionInterface::kNone:
|
||||
@ -1212,13 +1213,15 @@ bool WebRtcSession::SetIceTransports(
|
||||
ConvertIceTransportTypeToCandidateFilter(type));
|
||||
}
|
||||
|
||||
bool WebRtcSession::GetLocalTrackIdBySsrc(uint32 ssrc, std::string* track_id) {
|
||||
bool WebRtcSession::GetLocalTrackIdBySsrc(uint32_t ssrc,
|
||||
std::string* track_id) {
|
||||
if (!base_local_description())
|
||||
return false;
|
||||
return webrtc::GetTrackIdBySsrc(base_local_description(), ssrc, track_id);
|
||||
}
|
||||
|
||||
bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32 ssrc, std::string* track_id) {
|
||||
bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32_t ssrc,
|
||||
std::string* track_id) {
|
||||
if (!base_remote_description())
|
||||
return false;
|
||||
return webrtc::GetTrackIdBySsrc(base_remote_description(), ssrc, track_id);
|
||||
@ -1230,7 +1233,8 @@ std::string WebRtcSession::BadStateErrMsg(State state) {
|
||||
return desc.str();
|
||||
}
|
||||
|
||||
void WebRtcSession::SetAudioPlayout(uint32 ssrc, bool enable,
|
||||
void WebRtcSession::SetAudioPlayout(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::AudioRenderer* renderer) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
if (!voice_channel_) {
|
||||
@ -1250,7 +1254,8 @@ void WebRtcSession::SetAudioPlayout(uint32 ssrc, bool enable,
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcSession::SetAudioSend(uint32 ssrc, bool enable,
|
||||
void WebRtcSession::SetAudioSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::AudioOptions& options,
|
||||
cricket::AudioRenderer* renderer) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
@ -1263,7 +1268,7 @@ void WebRtcSession::SetAudioSend(uint32 ssrc, bool enable,
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcSession::SetAudioPlayoutVolume(uint32 ssrc, double volume) {
|
||||
void WebRtcSession::SetAudioPlayoutVolume(uint32_t ssrc, double volume) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
ASSERT(volume >= 0 && volume <= 10);
|
||||
if (!voice_channel_) {
|
||||
@ -1276,7 +1281,7 @@ void WebRtcSession::SetAudioPlayoutVolume(uint32 ssrc, double volume) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRtcSession::SetCaptureDevice(uint32 ssrc,
|
||||
bool WebRtcSession::SetCaptureDevice(uint32_t ssrc,
|
||||
cricket::VideoCapturer* camera) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
|
||||
@ -1296,7 +1301,7 @@ bool WebRtcSession::SetCaptureDevice(uint32 ssrc,
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRtcSession::SetVideoPlayout(uint32 ssrc,
|
||||
void WebRtcSession::SetVideoPlayout(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::VideoRenderer* renderer) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
@ -1312,7 +1317,8 @@ void WebRtcSession::SetVideoPlayout(uint32 ssrc,
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcSession::SetVideoSend(uint32 ssrc, bool enable,
|
||||
void WebRtcSession::SetVideoSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::VideoOptions* options) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
if (!video_channel_) {
|
||||
@ -1333,7 +1339,7 @@ bool WebRtcSession::CanInsertDtmf(const std::string& track_id) {
|
||||
LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists.";
|
||||
return false;
|
||||
}
|
||||
uint32 send_ssrc = 0;
|
||||
uint32_t send_ssrc = 0;
|
||||
// The Dtmf is negotiated per channel not ssrc, so we only check if the ssrc
|
||||
// exists.
|
||||
if (!GetAudioSsrcByTrackId(base_local_description(), track_id,
|
||||
@ -1351,7 +1357,7 @@ bool WebRtcSession::InsertDtmf(const std::string& track_id,
|
||||
LOG(LS_ERROR) << "InsertDtmf: No audio channel exists.";
|
||||
return false;
|
||||
}
|
||||
uint32 send_ssrc = 0;
|
||||
uint32_t send_ssrc = 0;
|
||||
if (!VERIFY(GetAudioSsrcByTrackId(base_local_description(),
|
||||
track_id, &send_ssrc))) {
|
||||
LOG(LS_ERROR) << "InsertDtmf: Track does not exist: " << track_id;
|
||||
|
||||
@ -198,25 +198,25 @@ class WebRtcSession : public cricket::BaseSession,
|
||||
}
|
||||
|
||||
// Get the id used as a media stream track's "id" field from ssrc.
|
||||
virtual bool GetLocalTrackIdBySsrc(uint32 ssrc, std::string* track_id);
|
||||
virtual bool GetRemoteTrackIdBySsrc(uint32 ssrc, std::string* track_id);
|
||||
virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id);
|
||||
virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id);
|
||||
|
||||
// AudioMediaProviderInterface implementation.
|
||||
void SetAudioPlayout(uint32 ssrc,
|
||||
void SetAudioPlayout(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::AudioRenderer* renderer) override;
|
||||
void SetAudioSend(uint32 ssrc,
|
||||
void SetAudioSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::AudioOptions& options,
|
||||
cricket::AudioRenderer* renderer) override;
|
||||
void SetAudioPlayoutVolume(uint32 ssrc, double volume) override;
|
||||
void SetAudioPlayoutVolume(uint32_t ssrc, double volume) override;
|
||||
|
||||
// Implements VideoMediaProviderInterface.
|
||||
bool SetCaptureDevice(uint32 ssrc, cricket::VideoCapturer* camera) override;
|
||||
void SetVideoPlayout(uint32 ssrc,
|
||||
bool SetCaptureDevice(uint32_t ssrc, cricket::VideoCapturer* camera) override;
|
||||
void SetVideoPlayout(uint32_t ssrc,
|
||||
bool enable,
|
||||
cricket::VideoRenderer* renderer) override;
|
||||
void SetVideoSend(uint32 ssrc,
|
||||
void SetVideoSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const cricket::VideoOptions* options) override;
|
||||
|
||||
|
||||
@ -1465,8 +1465,8 @@ TEST_F(WebRtcSessionTest, TestCreateSdesOfferReceiveSdesAnswer) {
|
||||
// Verify the session id is the same and the session version is
|
||||
// increased.
|
||||
EXPECT_EQ(session_id_orig, offer->session_id());
|
||||
EXPECT_LT(rtc::FromString<uint64>(session_version_orig),
|
||||
rtc::FromString<uint64>(offer->session_version()));
|
||||
EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig),
|
||||
rtc::FromString<uint64_t>(offer->session_version()));
|
||||
|
||||
SetLocalDescriptionWithoutError(offer);
|
||||
EXPECT_EQ(0u, video_channel_->send_streams().size());
|
||||
@ -1525,8 +1525,8 @@ TEST_F(WebRtcSessionTest, TestReceiveSdesOfferCreateSdesAnswer) {
|
||||
// Verify the session id is the same and the session version is
|
||||
// increased.
|
||||
EXPECT_EQ(session_id_orig, answer->session_id());
|
||||
EXPECT_LT(rtc::FromString<uint64>(session_version_orig),
|
||||
rtc::FromString<uint64>(answer->session_version()));
|
||||
EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig),
|
||||
rtc::FromString<uint64_t>(answer->session_version()));
|
||||
SetLocalDescriptionWithoutError(answer);
|
||||
|
||||
ASSERT_EQ(2u, video_channel_->recv_streams().size());
|
||||
@ -3107,7 +3107,7 @@ TEST_F(WebRtcSessionTest, SetAudioPlayout) {
|
||||
cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
|
||||
ASSERT_TRUE(channel != NULL);
|
||||
ASSERT_EQ(1u, channel->recv_streams().size());
|
||||
uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc();
|
||||
uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
|
||||
double left_vol, right_vol;
|
||||
EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol));
|
||||
EXPECT_EQ(1, left_vol);
|
||||
@ -3132,7 +3132,7 @@ TEST_F(WebRtcSessionTest, SetAudioSend) {
|
||||
cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
|
||||
ASSERT_TRUE(channel != NULL);
|
||||
ASSERT_EQ(1u, channel->send_streams().size());
|
||||
uint32 send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
|
||||
|
||||
cricket::AudioOptions options;
|
||||
@ -3162,7 +3162,7 @@ TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) {
|
||||
cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
|
||||
ASSERT_TRUE(channel != NULL);
|
||||
ASSERT_EQ(1u, channel->send_streams().size());
|
||||
uint32 send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
|
||||
rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer());
|
||||
cricket::AudioOptions options;
|
||||
@ -3187,7 +3187,7 @@ TEST_F(WebRtcSessionTest, SetVideoPlayout) {
|
||||
ASSERT_LT(0u, channel->renderers().size());
|
||||
EXPECT_TRUE(channel->renderers().begin()->second == NULL);
|
||||
ASSERT_EQ(1u, channel->recv_streams().size());
|
||||
uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc();
|
||||
uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
|
||||
cricket::FakeVideoRenderer renderer;
|
||||
session_->SetVideoPlayout(receive_ssrc, true, &renderer);
|
||||
EXPECT_TRUE(channel->renderers().begin()->second == &renderer);
|
||||
@ -3202,7 +3202,7 @@ TEST_F(WebRtcSessionTest, SetVideoSend) {
|
||||
cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0);
|
||||
ASSERT_TRUE(channel != NULL);
|
||||
ASSERT_EQ(1u, channel->send_streams().size());
|
||||
uint32 send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
|
||||
cricket::VideoOptions* options = NULL;
|
||||
session_->SetVideoSend(send_ssrc, false, options);
|
||||
@ -3236,7 +3236,7 @@ TEST_F(WebRtcSessionTest, InsertDtmf) {
|
||||
|
||||
// Verify
|
||||
ASSERT_EQ(3U, channel->dtmf_info_queue().size());
|
||||
const uint32 send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
|
||||
EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0,
|
||||
expected_duration, expected_flags));
|
||||
EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1,
|
||||
|
||||
@ -44,7 +44,7 @@ static const char kFailedDueToIdentityFailed[] =
|
||||
static const char kFailedDueToSessionShutdown[] =
|
||||
" failed because the session was shut down";
|
||||
|
||||
static const uint64 kInitSessionVersion = 2;
|
||||
static const uint64_t kInitSessionVersion = 2;
|
||||
|
||||
static bool CompareStream(const MediaSessionOptions::Stream& stream1,
|
||||
const MediaSessionOptions::Stream& stream2) {
|
||||
@ -415,7 +415,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer(
|
||||
|
||||
// Just increase the version number by one each time when a new offer
|
||||
// is created regardless if it's identical to the previous one or not.
|
||||
// The |session_version_| is a uint64, the wrap around should not happen.
|
||||
// The |session_version_| is a uint64_t, the wrap around should not happen.
|
||||
ASSERT(session_version_ + 1 > session_version_);
|
||||
JsepSessionDescription* offer(new JsepSessionDescription(
|
||||
JsepSessionDescription::kOffer));
|
||||
@ -459,7 +459,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
|
||||
// In that case, the version number in the "o=" line of the answer is
|
||||
// unrelated to the version number in the o line of the offer.
|
||||
// Get a new version number by increasing the |session_version_answer_|.
|
||||
// The |session_version_| is a uint64, the wrap around should not happen.
|
||||
// The |session_version_| is a uint64_t, the wrap around should not happen.
|
||||
ASSERT(session_version_ + 1 > session_version_);
|
||||
JsepSessionDescription* answer(new JsepSessionDescription(
|
||||
JsepSessionDescription::kAnswer));
|
||||
|
||||
@ -186,7 +186,7 @@ class WebRtcSessionDescriptionFactory : public rtc::MessageHandler,
|
||||
MediaStreamSignaling* const mediastream_signaling_;
|
||||
cricket::TransportDescriptionFactory transport_desc_factory_;
|
||||
cricket::MediaSessionDescriptionFactory session_desc_factory_;
|
||||
uint64 session_version_;
|
||||
uint64_t session_version_;
|
||||
const rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store_;
|
||||
const rtc::scoped_refptr<WebRtcIdentityRequestObserver>
|
||||
identity_request_observer_;
|
||||
|
||||
9
talk/media/base/audioframe.h
Executable file → Normal file
9
talk/media/base/audioframe.h
Executable file → Normal file
@ -38,14 +38,13 @@ class AudioFrame {
|
||||
sampling_frequency_(8000),
|
||||
stereo_(false) {
|
||||
}
|
||||
AudioFrame(int16* audio, size_t audio_length, int sample_freq, bool stereo)
|
||||
AudioFrame(int16_t* audio, size_t audio_length, int sample_freq, bool stereo)
|
||||
: audio10ms_(audio),
|
||||
length_(audio_length),
|
||||
sampling_frequency_(sample_freq),
|
||||
stereo_(stereo) {
|
||||
}
|
||||
stereo_(stereo) {}
|
||||
|
||||
int16* GetData() { return audio10ms_; }
|
||||
int16_t* GetData() { return audio10ms_; }
|
||||
size_t GetSize() const { return length_; }
|
||||
int GetSamplingFrequency() const { return sampling_frequency_; }
|
||||
bool GetStereo() const { return stereo_; }
|
||||
@ -53,7 +52,7 @@ class AudioFrame {
|
||||
private:
|
||||
// TODO(janahan): currently the data is not owned by this class.
|
||||
// add ownership when we come up with the first use case that requires it.
|
||||
int16* audio10ms_;
|
||||
int16_t* audio10ms_;
|
||||
size_t length_;
|
||||
int sampling_frequency_;
|
||||
bool stereo_;
|
||||
|
||||
@ -43,7 +43,7 @@ void CpuInfo::MaskCpuFlagsForTest(int enable_flags) {
|
||||
bool IsCoreIOrBetter() {
|
||||
#if defined(__i386__) || defined(__x86_64__) || \
|
||||
defined(_M_IX86) || defined(_M_X64)
|
||||
uint32 cpu_info[4];
|
||||
uint32_t cpu_info[4];
|
||||
libyuv::CpuId(0, 0, &cpu_info[0]); // Function 0: Vendor ID
|
||||
if (cpu_info[1] == 0x756e6547 && cpu_info[3] == 0x49656e69 &&
|
||||
cpu_info[2] == 0x6c65746e) { // GenuineIntel
|
||||
|
||||
@ -42,7 +42,7 @@ namespace rtc {
|
||||
// Returns the path to the running executable or an empty path.
|
||||
// TODO(thorcarpenter): Consolidate with FluteClient::get_executable_dir.
|
||||
inline Pathname GetExecutablePath() {
|
||||
const int32 kMaxExePathSize = 255;
|
||||
const int32_t kMaxExePathSize = 255;
|
||||
#ifdef WIN32
|
||||
TCHAR exe_path_buffer[kMaxExePathSize];
|
||||
DWORD copied_length = GetModuleFileName(NULL, // NULL = Current process
|
||||
@ -71,7 +71,7 @@ inline Pathname GetExecutablePath() {
|
||||
return rtc::Pathname();
|
||||
}
|
||||
#elif defined LINUX
|
||||
int32 copied_length = kMaxExePathSize - 1;
|
||||
int32_t copied_length = kMaxExePathSize - 1;
|
||||
const char* kProcExeFmt = "/proc/%d/exe";
|
||||
char proc_exe_link[40];
|
||||
snprintf(proc_exe_link, sizeof(proc_exe_link), kProcExeFmt, getpid());
|
||||
|
||||
@ -113,7 +113,7 @@ template <class Base> class RtpHelper : public Base {
|
||||
send_streams_.push_back(sp);
|
||||
return true;
|
||||
}
|
||||
virtual bool RemoveSendStream(uint32 ssrc) {
|
||||
virtual bool RemoveSendStream(uint32_t ssrc) {
|
||||
return RemoveStreamBySsrc(&send_streams_, ssrc);
|
||||
}
|
||||
virtual bool AddRecvStream(const StreamParams& sp) {
|
||||
@ -124,10 +124,10 @@ template <class Base> class RtpHelper : public Base {
|
||||
receive_streams_.push_back(sp);
|
||||
return true;
|
||||
}
|
||||
virtual bool RemoveRecvStream(uint32 ssrc) {
|
||||
virtual bool RemoveRecvStream(uint32_t ssrc) {
|
||||
return RemoveStreamBySsrc(&receive_streams_, ssrc);
|
||||
}
|
||||
bool IsStreamMuted(uint32 ssrc) const {
|
||||
bool IsStreamMuted(uint32_t ssrc) const {
|
||||
bool ret = muted_streams_.find(ssrc) != muted_streams_.end();
|
||||
// If |ssrc = 0| check if the first send stream is muted.
|
||||
if (!ret && ssrc == 0 && !send_streams_.empty()) {
|
||||
@ -142,15 +142,15 @@ template <class Base> class RtpHelper : public Base {
|
||||
const std::vector<StreamParams>& recv_streams() const {
|
||||
return receive_streams_;
|
||||
}
|
||||
bool HasRecvStream(uint32 ssrc) const {
|
||||
bool HasRecvStream(uint32_t ssrc) const {
|
||||
return GetStreamBySsrc(receive_streams_, ssrc) != nullptr;
|
||||
}
|
||||
bool HasSendStream(uint32 ssrc) const {
|
||||
bool HasSendStream(uint32_t ssrc) const {
|
||||
return GetStreamBySsrc(send_streams_, ssrc) != nullptr;
|
||||
}
|
||||
// TODO(perkj): This is to support legacy unit test that only check one
|
||||
// sending stream.
|
||||
uint32 send_ssrc() const {
|
||||
uint32_t send_ssrc() const {
|
||||
if (send_streams_.empty())
|
||||
return 0;
|
||||
return send_streams_[0].first_ssrc();
|
||||
@ -169,7 +169,7 @@ template <class Base> class RtpHelper : public Base {
|
||||
}
|
||||
|
||||
protected:
|
||||
bool MuteStream(uint32 ssrc, bool mute) {
|
||||
bool MuteStream(uint32_t ssrc, bool mute) {
|
||||
if (!HasSendStream(ssrc) && ssrc != 0) {
|
||||
return false;
|
||||
}
|
||||
@ -218,10 +218,10 @@ template <class Base> class RtpHelper : public Base {
|
||||
std::list<std::string> rtcp_packets_;
|
||||
std::vector<StreamParams> send_streams_;
|
||||
std::vector<StreamParams> receive_streams_;
|
||||
std::set<uint32> muted_streams_;
|
||||
std::set<uint32_t> muted_streams_;
|
||||
bool fail_set_send_codecs_;
|
||||
bool fail_set_recv_codecs_;
|
||||
uint32 send_ssrc_;
|
||||
uint32_t send_ssrc_;
|
||||
std::string rtcp_cname_;
|
||||
bool ready_to_send_;
|
||||
};
|
||||
@ -229,10 +229,12 @@ template <class Base> class RtpHelper : public Base {
|
||||
class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
public:
|
||||
struct DtmfInfo {
|
||||
DtmfInfo(uint32 ssrc, int event_code, int duration, int flags)
|
||||
: ssrc(ssrc), event_code(event_code), duration(duration), flags(flags) {
|
||||
}
|
||||
uint32 ssrc;
|
||||
DtmfInfo(uint32_t ssrc, int event_code, int duration, int flags)
|
||||
: ssrc(ssrc),
|
||||
event_code(event_code),
|
||||
duration(duration),
|
||||
flags(flags) {}
|
||||
uint32_t ssrc;
|
||||
int event_code;
|
||||
int duration;
|
||||
int flags;
|
||||
@ -271,7 +273,8 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
virtual bool SetSend(SendFlags flag) {
|
||||
return set_sending(flag != SEND_NOTHING);
|
||||
}
|
||||
virtual bool SetAudioSend(uint32 ssrc, bool enable,
|
||||
virtual bool SetAudioSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const AudioOptions* options,
|
||||
AudioRenderer* renderer) {
|
||||
if (!SetLocalRenderer(ssrc, renderer)) {
|
||||
@ -291,14 +294,14 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
output_scalings_[sp.first_ssrc()] = OutputScaling();
|
||||
return true;
|
||||
}
|
||||
virtual bool RemoveRecvStream(uint32 ssrc) {
|
||||
virtual bool RemoveRecvStream(uint32_t ssrc) {
|
||||
if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc))
|
||||
return false;
|
||||
output_scalings_.erase(ssrc);
|
||||
return true;
|
||||
}
|
||||
virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) {
|
||||
std::map<uint32, AudioRenderer*>::iterator it =
|
||||
virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) {
|
||||
std::map<uint32_t, AudioRenderer*>::iterator it =
|
||||
remote_renderers_.find(ssrc);
|
||||
if (renderer) {
|
||||
if (it != remote_renderers_.end()) {
|
||||
@ -336,15 +339,17 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
virtual bool InsertDtmf(uint32 ssrc, int event_code, int duration,
|
||||
virtual bool InsertDtmf(uint32_t ssrc,
|
||||
int event_code,
|
||||
int duration,
|
||||
int flags) {
|
||||
dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags));
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool SetOutputScaling(uint32 ssrc, double left, double right) {
|
||||
virtual bool SetOutputScaling(uint32_t ssrc, double left, double right) {
|
||||
if (0 == ssrc) {
|
||||
std::map<uint32, OutputScaling>::iterator it;
|
||||
std::map<uint32_t, OutputScaling>::iterator it;
|
||||
for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) {
|
||||
it->second.left = left;
|
||||
it->second.right = right;
|
||||
@ -357,7 +362,7 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool GetOutputScaling(uint32 ssrc, double* left, double* right) {
|
||||
bool GetOutputScaling(uint32_t ssrc, double* left, double* right) {
|
||||
if (output_scalings_.find(ssrc) == output_scalings_.end())
|
||||
return false;
|
||||
*left = output_scalings_[ssrc].left;
|
||||
@ -420,7 +425,7 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
options_.SetAll(options);
|
||||
return true;
|
||||
}
|
||||
bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) {
|
||||
bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer) {
|
||||
auto it = local_renderers_.find(ssrc);
|
||||
if (renderer) {
|
||||
if (it != local_renderers_.end()) {
|
||||
@ -441,17 +446,19 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
FakeVoiceEngine* engine_;
|
||||
std::vector<AudioCodec> recv_codecs_;
|
||||
std::vector<AudioCodec> send_codecs_;
|
||||
std::map<uint32, OutputScaling> output_scalings_;
|
||||
std::map<uint32_t, OutputScaling> output_scalings_;
|
||||
std::vector<DtmfInfo> dtmf_info_queue_;
|
||||
int time_since_last_typing_;
|
||||
AudioOptions options_;
|
||||
std::map<uint32, VoiceChannelAudioSink*> local_renderers_;
|
||||
std::map<uint32, AudioRenderer*> remote_renderers_;
|
||||
std::map<uint32_t, VoiceChannelAudioSink*> local_renderers_;
|
||||
std::map<uint32_t, AudioRenderer*> remote_renderers_;
|
||||
};
|
||||
|
||||
// A helper function to compare the FakeVoiceMediaChannel::DtmfInfo.
|
||||
inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info,
|
||||
uint32 ssrc, int event_code, int duration,
|
||||
uint32_t ssrc,
|
||||
int event_code,
|
||||
int duration,
|
||||
int flags) {
|
||||
return (info.duration == duration && info.event_code == event_code &&
|
||||
info.flags == flags && info.ssrc == ssrc);
|
||||
@ -475,18 +482,18 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
const std::vector<VideoCodec>& codecs() const { return send_codecs(); }
|
||||
bool rendering() const { return playout(); }
|
||||
const VideoOptions& options() const { return options_; }
|
||||
const std::map<uint32, VideoRenderer*>& renderers() const {
|
||||
const std::map<uint32_t, VideoRenderer*>& renderers() const {
|
||||
return renderers_;
|
||||
}
|
||||
int max_bps() const { return max_bps_; }
|
||||
bool GetSendStreamFormat(uint32 ssrc, VideoFormat* format) {
|
||||
bool GetSendStreamFormat(uint32_t ssrc, VideoFormat* format) {
|
||||
if (send_formats_.find(ssrc) == send_formats_.end()) {
|
||||
return false;
|
||||
}
|
||||
*format = send_formats_[ssrc];
|
||||
return true;
|
||||
}
|
||||
virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) {
|
||||
virtual bool SetSendStreamFormat(uint32_t ssrc, const VideoFormat& format) {
|
||||
if (send_formats_.find(ssrc) == send_formats_.end()) {
|
||||
return false;
|
||||
}
|
||||
@ -511,7 +518,7 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
SetSendStreamDefaultFormat(sp.first_ssrc());
|
||||
return true;
|
||||
}
|
||||
virtual bool RemoveSendStream(uint32 ssrc) {
|
||||
virtual bool RemoveSendStream(uint32_t ssrc) {
|
||||
send_formats_.erase(ssrc);
|
||||
return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc);
|
||||
}
|
||||
@ -523,7 +530,7 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
*send_codec = send_codecs_[0];
|
||||
return true;
|
||||
}
|
||||
virtual bool SetRenderer(uint32 ssrc, VideoRenderer* r) {
|
||||
virtual bool SetRenderer(uint32_t ssrc, VideoRenderer* r) {
|
||||
if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) {
|
||||
return false;
|
||||
}
|
||||
@ -534,7 +541,7 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
}
|
||||
|
||||
virtual bool SetSend(bool send) { return set_sending(send); }
|
||||
virtual bool SetVideoSend(uint32 ssrc, bool enable,
|
||||
virtual bool SetVideoSend(uint32_t ssrc, bool enable,
|
||||
const VideoOptions* options) {
|
||||
if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, !enable)) {
|
||||
return false;
|
||||
@ -544,11 +551,11 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) {
|
||||
virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) {
|
||||
capturers_[ssrc] = capturer;
|
||||
return true;
|
||||
}
|
||||
bool HasCapturer(uint32 ssrc) const {
|
||||
bool HasCapturer(uint32_t ssrc) const {
|
||||
return capturers_.find(ssrc) != capturers_.end();
|
||||
}
|
||||
virtual bool AddRecvStream(const StreamParams& sp) {
|
||||
@ -557,7 +564,7 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
renderers_[sp.first_ssrc()] = NULL;
|
||||
return true;
|
||||
}
|
||||
virtual bool RemoveRecvStream(uint32 ssrc) {
|
||||
virtual bool RemoveRecvStream(uint32_t ssrc) {
|
||||
if (!RtpHelper<VideoMediaChannel>::RemoveRecvStream(ssrc))
|
||||
return false;
|
||||
renderers_.erase(ssrc);
|
||||
@ -611,7 +618,7 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
}
|
||||
|
||||
// Be default, each send stream uses the first send codec format.
|
||||
void SetSendStreamDefaultFormat(uint32 ssrc) {
|
||||
void SetSendStreamDefaultFormat(uint32_t ssrc) {
|
||||
if (!send_codecs_.empty()) {
|
||||
send_formats_[ssrc] = VideoFormat(
|
||||
send_codecs_[0].width, send_codecs_[0].height,
|
||||
@ -623,9 +630,9 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
|
||||
FakeVideoEngine* engine_;
|
||||
std::vector<VideoCodec> recv_codecs_;
|
||||
std::vector<VideoCodec> send_codecs_;
|
||||
std::map<uint32, VideoRenderer*> renderers_;
|
||||
std::map<uint32, VideoFormat> send_formats_;
|
||||
std::map<uint32, VideoCapturer*> capturers_;
|
||||
std::map<uint32_t, VideoRenderer*> renderers_;
|
||||
std::map<uint32_t, VideoFormat> send_formats_;
|
||||
std::map<uint32_t, VideoCapturer*> capturers_;
|
||||
bool sent_intra_frame_;
|
||||
bool requested_intra_frame_;
|
||||
VideoOptions options_;
|
||||
@ -659,7 +666,7 @@ class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
virtual bool RemoveRecvStream(uint32 ssrc) {
|
||||
virtual bool RemoveRecvStream(uint32_t ssrc) {
|
||||
if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@ -61,7 +61,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
// Conference mode is a mode where instead of simply forwarding the packets,
|
||||
// the transport will send multiple copies of the packet with the specified
|
||||
// SSRCs. This allows us to simulate receiving media from multiple sources.
|
||||
void SetConferenceMode(bool conf, const std::vector<uint32>& ssrcs) {
|
||||
void SetConferenceMode(bool conf, const std::vector<uint32_t>& ssrcs) {
|
||||
rtc::CritScope cs(&crit_);
|
||||
conf_ = conf;
|
||||
conf_sent_ssrcs_ = ssrcs;
|
||||
@ -76,7 +76,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
return bytes;
|
||||
}
|
||||
|
||||
int NumRtpBytes(uint32 ssrc) {
|
||||
int NumRtpBytes(uint32_t ssrc) {
|
||||
rtc::CritScope cs(&crit_);
|
||||
int bytes = 0;
|
||||
GetNumRtpBytesAndPackets(ssrc, &bytes, NULL);
|
||||
@ -88,7 +88,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
return static_cast<int>(rtp_packets_.size());
|
||||
}
|
||||
|
||||
int NumRtpPackets(uint32 ssrc) {
|
||||
int NumRtpPackets(uint32_t ssrc) {
|
||||
rtc::CritScope cs(&crit_);
|
||||
int packets = 0;
|
||||
GetNumRtpBytesAndPackets(ssrc, NULL, &packets);
|
||||
@ -132,7 +132,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
rtc::DiffServCodePoint dscp) {
|
||||
rtc::CritScope cs(&crit_);
|
||||
|
||||
uint32 cur_ssrc = 0;
|
||||
uint32_t cur_ssrc = 0;
|
||||
if (!GetRtpSsrc(packet->data(), packet->size(), &cur_ssrc)) {
|
||||
return false;
|
||||
}
|
||||
@ -198,14 +198,14 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
}
|
||||
|
||||
private:
|
||||
void GetNumRtpBytesAndPackets(uint32 ssrc, int* bytes, int* packets) {
|
||||
void GetNumRtpBytesAndPackets(uint32_t ssrc, int* bytes, int* packets) {
|
||||
if (bytes) {
|
||||
*bytes = 0;
|
||||
}
|
||||
if (packets) {
|
||||
*packets = 0;
|
||||
}
|
||||
uint32 cur_ssrc = 0;
|
||||
uint32_t cur_ssrc = 0;
|
||||
for (size_t i = 0; i < rtp_packets_.size(); ++i) {
|
||||
if (!GetRtpSsrc(rtp_packets_[i].data(), rtp_packets_[i].size(),
|
||||
&cur_ssrc)) {
|
||||
@ -226,12 +226,12 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
|
||||
MediaChannel* dest_;
|
||||
bool conf_;
|
||||
// The ssrcs used in sending out packets in conference mode.
|
||||
std::vector<uint32> conf_sent_ssrcs_;
|
||||
std::vector<uint32_t> conf_sent_ssrcs_;
|
||||
// Map to track counts of packets that have been sent per ssrc.
|
||||
// This includes packets that are dropped.
|
||||
std::map<uint32, uint32> sent_ssrcs_;
|
||||
std::map<uint32_t, uint32_t> sent_ssrcs_;
|
||||
// Map to track packet-number that needs to be dropped per ssrc.
|
||||
std::map<uint32, std::set<uint32> > drop_map_;
|
||||
std::map<uint32_t, std::set<uint32_t> > drop_map_;
|
||||
rtc::CriticalSection crit_;
|
||||
std::vector<rtc::Buffer> rtp_packets_;
|
||||
std::vector<rtc::Buffer> rtcp_packets_;
|
||||
|
||||
@ -84,24 +84,24 @@ class FakeVideoCapturer : public cricket::VideoCapturer {
|
||||
GetCaptureFormat()->interval,
|
||||
GetCaptureFormat()->fourcc);
|
||||
}
|
||||
bool CaptureCustomFrame(int width, int height, uint32 fourcc) {
|
||||
bool CaptureCustomFrame(int width, int height, uint32_t fourcc) {
|
||||
// default to 30fps
|
||||
return CaptureCustomFrame(width, height, 33333333, fourcc);
|
||||
}
|
||||
bool CaptureCustomFrame(int width,
|
||||
int height,
|
||||
int64_t timestamp_interval,
|
||||
uint32 fourcc) {
|
||||
uint32_t fourcc) {
|
||||
if (!running_) {
|
||||
return false;
|
||||
}
|
||||
// Currently, |fourcc| is always I420 or ARGB.
|
||||
// TODO(fbarchard): Extend SizeOf to take fourcc.
|
||||
uint32 size = 0u;
|
||||
uint32_t size = 0u;
|
||||
if (fourcc == cricket::FOURCC_ARGB) {
|
||||
size = width * 4 * height;
|
||||
} else if (fourcc == cricket::FOURCC_I420) {
|
||||
size = static_cast<uint32>(cricket::VideoFrame::SizeOf(width, height));
|
||||
size = static_cast<uint32_t>(cricket::VideoFrame::SizeOf(width, height));
|
||||
} else {
|
||||
return false; // Unsupported FOURCC.
|
||||
}
|
||||
@ -122,9 +122,9 @@ class FakeVideoCapturer : public cricket::VideoCapturer {
|
||||
// Copy something non-zero into the buffer so Validate wont complain that
|
||||
// the frame is all duplicate.
|
||||
memset(frame.data, 1, size / 2);
|
||||
memset(reinterpret_cast<uint8*>(frame.data) + (size / 2), 2,
|
||||
size - (size / 2));
|
||||
memcpy(frame.data, reinterpret_cast<const uint8*>(&fourcc), 4);
|
||||
memset(reinterpret_cast<uint8_t*>(frame.data) + (size / 2), 2,
|
||||
size - (size / 2));
|
||||
memcpy(frame.data, reinterpret_cast<const uint8_t*>(&fourcc), 4);
|
||||
frame.rotation = rotation_;
|
||||
// TODO(zhurunz): SignalFrameCaptured carry returned value to be able to
|
||||
// capture results from downstream.
|
||||
@ -157,7 +157,7 @@ class FakeVideoCapturer : public cricket::VideoCapturer {
|
||||
is_screencast_ = is_screencast;
|
||||
}
|
||||
virtual bool IsScreencast() const { return is_screencast_; }
|
||||
bool GetPreferredFourccs(std::vector<uint32>* fourccs) {
|
||||
bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
|
||||
fourccs->push_back(cricket::FOURCC_I420);
|
||||
fourccs->push_back(cricket::FOURCC_MJPG);
|
||||
return true;
|
||||
@ -171,8 +171,8 @@ class FakeVideoCapturer : public cricket::VideoCapturer {
|
||||
|
||||
private:
|
||||
bool running_;
|
||||
int64 initial_unix_timestamp_;
|
||||
int64 next_timestamp_;
|
||||
int64_t initial_unix_timestamp_;
|
||||
int64_t next_timestamp_;
|
||||
bool is_screencast_;
|
||||
webrtc::VideoRotation rotation_;
|
||||
};
|
||||
|
||||
@ -106,9 +106,12 @@ class FakeVideoRenderer : public VideoRenderer {
|
||||
sigslot::signal1<const VideoFrame*> SignalRenderFrame;
|
||||
|
||||
private:
|
||||
static bool CheckFrameColorYuv(uint8 y_min, uint8 y_max,
|
||||
uint8 u_min, uint8 u_max,
|
||||
uint8 v_min, uint8 v_max,
|
||||
static bool CheckFrameColorYuv(uint8_t y_min,
|
||||
uint8_t y_max,
|
||||
uint8_t u_min,
|
||||
uint8_t u_max,
|
||||
uint8_t v_min,
|
||||
uint8_t v_max,
|
||||
const cricket::VideoFrame* frame) {
|
||||
if (!frame) {
|
||||
return false;
|
||||
@ -116,12 +119,12 @@ class FakeVideoRenderer : public VideoRenderer {
|
||||
// Y
|
||||
size_t y_width = frame->GetWidth();
|
||||
size_t y_height = frame->GetHeight();
|
||||
const uint8* y_plane = frame->GetYPlane();
|
||||
const uint8* y_pos = y_plane;
|
||||
int32 y_pitch = frame->GetYPitch();
|
||||
const uint8_t* y_plane = frame->GetYPlane();
|
||||
const uint8_t* y_pos = y_plane;
|
||||
int32_t y_pitch = frame->GetYPitch();
|
||||
for (size_t i = 0; i < y_height; ++i) {
|
||||
for (size_t j = 0; j < y_width; ++j) {
|
||||
uint8 y_value = *(y_pos + j);
|
||||
uint8_t y_value = *(y_pos + j);
|
||||
if (y_value < y_min || y_value > y_max) {
|
||||
return false;
|
||||
}
|
||||
@ -131,19 +134,19 @@ class FakeVideoRenderer : public VideoRenderer {
|
||||
// U and V
|
||||
size_t chroma_width = frame->GetChromaWidth();
|
||||
size_t chroma_height = frame->GetChromaHeight();
|
||||
const uint8* u_plane = frame->GetUPlane();
|
||||
const uint8* v_plane = frame->GetVPlane();
|
||||
const uint8* u_pos = u_plane;
|
||||
const uint8* v_pos = v_plane;
|
||||
int32 u_pitch = frame->GetUPitch();
|
||||
int32 v_pitch = frame->GetVPitch();
|
||||
const uint8_t* u_plane = frame->GetUPlane();
|
||||
const uint8_t* v_plane = frame->GetVPlane();
|
||||
const uint8_t* u_pos = u_plane;
|
||||
const uint8_t* v_pos = v_plane;
|
||||
int32_t u_pitch = frame->GetUPitch();
|
||||
int32_t v_pitch = frame->GetVPitch();
|
||||
for (size_t i = 0; i < chroma_height; ++i) {
|
||||
for (size_t j = 0; j < chroma_width; ++j) {
|
||||
uint8 u_value = *(u_pos + j);
|
||||
uint8_t u_value = *(u_pos + j);
|
||||
if (u_value < u_min || u_value > u_max) {
|
||||
return false;
|
||||
}
|
||||
uint8 v_value = *(v_pos + j);
|
||||
uint8_t v_value = *(v_pos + j);
|
||||
if (v_value < v_min || v_value > v_max) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -288,14 +288,14 @@ struct AudioOptions {
|
||||
Settable<bool> experimental_ns;
|
||||
Settable<bool> aec_dump;
|
||||
// Note that tx_agc_* only applies to non-experimental AGC.
|
||||
Settable<uint16> tx_agc_target_dbov;
|
||||
Settable<uint16> tx_agc_digital_compression_gain;
|
||||
Settable<uint16_t> tx_agc_target_dbov;
|
||||
Settable<uint16_t> tx_agc_digital_compression_gain;
|
||||
Settable<bool> tx_agc_limiter;
|
||||
Settable<uint16> rx_agc_target_dbov;
|
||||
Settable<uint16> rx_agc_digital_compression_gain;
|
||||
Settable<uint16_t> rx_agc_target_dbov;
|
||||
Settable<uint16_t> rx_agc_digital_compression_gain;
|
||||
Settable<bool> rx_agc_limiter;
|
||||
Settable<uint32> recording_sample_rate;
|
||||
Settable<uint32> playout_sample_rate;
|
||||
Settable<uint32_t> recording_sample_rate;
|
||||
Settable<uint32_t> playout_sample_rate;
|
||||
// Set DSCP value for packet sent from audio channel.
|
||||
Settable<bool> dscp;
|
||||
// Enable combined audio+bandwidth BWE.
|
||||
@ -557,14 +557,14 @@ class MediaChannel : public sigslot::has_slots<> {
|
||||
// Removes an outgoing media stream.
|
||||
// ssrc must be the first SSRC of the media stream if the stream uses
|
||||
// multiple SSRCs.
|
||||
virtual bool RemoveSendStream(uint32 ssrc) = 0;
|
||||
virtual bool RemoveSendStream(uint32_t ssrc) = 0;
|
||||
// Creates a new incoming media stream with SSRCs and CNAME as described
|
||||
// by sp.
|
||||
virtual bool AddRecvStream(const StreamParams& sp) = 0;
|
||||
// Removes an incoming media stream.
|
||||
// ssrc must be the first SSRC of the media stream if the stream uses
|
||||
// multiple SSRCs.
|
||||
virtual bool RemoveRecvStream(uint32 ssrc) = 0;
|
||||
virtual bool RemoveRecvStream(uint32_t ssrc) = 0;
|
||||
|
||||
// Returns the absoulte sendtime extension id value from media channel.
|
||||
virtual int GetRtpSendTimeExtnId() const {
|
||||
@ -640,7 +640,7 @@ struct SsrcSenderInfo {
|
||||
: ssrc(0),
|
||||
timestamp(0) {
|
||||
}
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
double timestamp; // NTP timestamp, represented as seconds since epoch.
|
||||
};
|
||||
|
||||
@ -649,7 +649,7 @@ struct SsrcReceiverInfo {
|
||||
: ssrc(0),
|
||||
timestamp(0) {
|
||||
}
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
double timestamp;
|
||||
};
|
||||
|
||||
@ -666,14 +666,14 @@ struct MediaSenderInfo {
|
||||
}
|
||||
// Temporary utility function for call sites that only provide SSRC.
|
||||
// As more info is added into SsrcSenderInfo, this function should go away.
|
||||
void add_ssrc(uint32 ssrc) {
|
||||
void add_ssrc(uint32_t ssrc) {
|
||||
SsrcSenderInfo stat;
|
||||
stat.ssrc = ssrc;
|
||||
add_ssrc(stat);
|
||||
}
|
||||
// Utility accessor for clients that are only interested in ssrc numbers.
|
||||
std::vector<uint32> ssrcs() const {
|
||||
std::vector<uint32> retval;
|
||||
std::vector<uint32_t> ssrcs() const {
|
||||
std::vector<uint32_t> retval;
|
||||
for (std::vector<SsrcSenderInfo>::const_iterator it = local_stats.begin();
|
||||
it != local_stats.end(); ++it) {
|
||||
retval.push_back(it->ssrc);
|
||||
@ -683,14 +683,14 @@ struct MediaSenderInfo {
|
||||
// Utility accessor for clients that make the assumption only one ssrc
|
||||
// exists per media.
|
||||
// This will eventually go away.
|
||||
uint32 ssrc() const {
|
||||
uint32_t ssrc() const {
|
||||
if (local_stats.size() > 0) {
|
||||
return local_stats[0].ssrc;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int64 bytes_sent;
|
||||
int64_t bytes_sent;
|
||||
int packets_sent;
|
||||
int packets_lost;
|
||||
float fraction_lost;
|
||||
@ -726,13 +726,13 @@ struct MediaReceiverInfo {
|
||||
}
|
||||
// Temporary utility function for call sites that only provide SSRC.
|
||||
// As more info is added into SsrcSenderInfo, this function should go away.
|
||||
void add_ssrc(uint32 ssrc) {
|
||||
void add_ssrc(uint32_t ssrc) {
|
||||
SsrcReceiverInfo stat;
|
||||
stat.ssrc = ssrc;
|
||||
add_ssrc(stat);
|
||||
}
|
||||
std::vector<uint32> ssrcs() const {
|
||||
std::vector<uint32> retval;
|
||||
std::vector<uint32_t> ssrcs() const {
|
||||
std::vector<uint32_t> retval;
|
||||
for (std::vector<SsrcReceiverInfo>::const_iterator it = local_stats.begin();
|
||||
it != local_stats.end(); ++it) {
|
||||
retval.push_back(it->ssrc);
|
||||
@ -742,7 +742,7 @@ struct MediaReceiverInfo {
|
||||
// Utility accessor for clients that make the assumption only one ssrc
|
||||
// exists per media.
|
||||
// This will eventually go away.
|
||||
uint32 ssrc() const {
|
||||
uint32_t ssrc() const {
|
||||
if (local_stats.size() > 0) {
|
||||
return local_stats[0].ssrc;
|
||||
} else {
|
||||
@ -750,7 +750,7 @@ struct MediaReceiverInfo {
|
||||
}
|
||||
}
|
||||
|
||||
int64 bytes_rcvd;
|
||||
int64_t bytes_rcvd;
|
||||
int packets_rcvd;
|
||||
int packets_lost;
|
||||
float fraction_lost;
|
||||
@ -827,7 +827,7 @@ struct VoiceReceiverInfo : public MediaReceiverInfo {
|
||||
int decoding_cng;
|
||||
int decoding_plc_cng;
|
||||
// Estimated capture start time in NTP time in ms.
|
||||
int64 capture_start_ntp_time_ms;
|
||||
int64_t capture_start_ntp_time_ms;
|
||||
};
|
||||
|
||||
struct VideoSenderInfo : public MediaSenderInfo {
|
||||
@ -931,7 +931,7 @@ struct VideoReceiverInfo : public MediaReceiverInfo {
|
||||
int current_delay_ms;
|
||||
|
||||
// Estimated capture start time in NTP time in ms.
|
||||
int64 capture_start_ntp_time_ms;
|
||||
int64_t capture_start_ntp_time_ms;
|
||||
};
|
||||
|
||||
struct DataSenderInfo : public MediaSenderInfo {
|
||||
@ -939,7 +939,7 @@ struct DataSenderInfo : public MediaSenderInfo {
|
||||
: ssrc(0) {
|
||||
}
|
||||
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
};
|
||||
|
||||
struct DataReceiverInfo : public MediaReceiverInfo {
|
||||
@ -947,7 +947,7 @@ struct DataReceiverInfo : public MediaReceiverInfo {
|
||||
: ssrc(0) {
|
||||
}
|
||||
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
};
|
||||
|
||||
struct BandwidthEstimationInfo {
|
||||
@ -1070,11 +1070,12 @@ class VoiceMediaChannel : public MediaChannel {
|
||||
// Starts or stops sending (and potentially capture) of local audio.
|
||||
virtual bool SetSend(SendFlags flag) = 0;
|
||||
// Configure stream for sending.
|
||||
virtual bool SetAudioSend(uint32 ssrc, bool enable,
|
||||
virtual bool SetAudioSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const AudioOptions* options,
|
||||
AudioRenderer* renderer) = 0;
|
||||
// Sets the renderer object to be used for the specified remote audio stream.
|
||||
virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) = 0;
|
||||
virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) = 0;
|
||||
// Gets current energy levels for all incoming streams.
|
||||
virtual bool GetActiveStreams(AudioInfo::StreamList* actives) = 0;
|
||||
// Get the current energy level of the stream sent to the speaker.
|
||||
@ -1086,7 +1087,7 @@ class VoiceMediaChannel : public MediaChannel {
|
||||
int cost_per_typing, int reporting_threshold, int penalty_decay,
|
||||
int type_event_delay) = 0;
|
||||
// Set left and right scale for speaker output volume of the specified ssrc.
|
||||
virtual bool SetOutputScaling(uint32 ssrc, double left, double right) = 0;
|
||||
virtual bool SetOutputScaling(uint32_t ssrc, double left, double right) = 0;
|
||||
// Returns if the telephone-event has been negotiated.
|
||||
virtual bool CanInsertDtmf() { return false; }
|
||||
// Send and/or play a DTMF |event| according to the |flags|.
|
||||
@ -1094,7 +1095,10 @@ class VoiceMediaChannel : public MediaChannel {
|
||||
// The |ssrc| should be either 0 or a valid send stream ssrc.
|
||||
// The valid value for the |event| are 0 to 15 which corresponding to
|
||||
// DTMF event 0-9, *, #, A-D.
|
||||
virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) = 0;
|
||||
virtual bool InsertDtmf(uint32_t ssrc,
|
||||
int event,
|
||||
int duration,
|
||||
int flags) = 0;
|
||||
// Gets quality stats for the channel.
|
||||
virtual bool GetStats(VoiceMediaInfo* info) = 0;
|
||||
};
|
||||
@ -1130,18 +1134,20 @@ class VideoMediaChannel : public MediaChannel {
|
||||
// Gets the currently set codecs/payload types to be used for outgoing media.
|
||||
virtual bool GetSendCodec(VideoCodec* send_codec) = 0;
|
||||
// Sets the format of a specified outgoing stream.
|
||||
virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) = 0;
|
||||
virtual bool SetSendStreamFormat(uint32_t ssrc,
|
||||
const VideoFormat& format) = 0;
|
||||
// Starts or stops transmission (and potentially capture) of local video.
|
||||
virtual bool SetSend(bool send) = 0;
|
||||
// Configure stream for sending.
|
||||
virtual bool SetVideoSend(uint32 ssrc, bool enable,
|
||||
virtual bool SetVideoSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
const VideoOptions* options) = 0;
|
||||
// Sets the renderer object to be used for the specified stream.
|
||||
// If SSRC is 0, the renderer is used for the 'default' stream.
|
||||
virtual bool SetRenderer(uint32 ssrc, VideoRenderer* renderer) = 0;
|
||||
virtual bool SetRenderer(uint32_t ssrc, VideoRenderer* renderer) = 0;
|
||||
// If |ssrc| is 0, replace the default capturer (engine capturer) with
|
||||
// |capturer|. If |ssrc| is non zero create a new stream with |ssrc| as SSRC.
|
||||
virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) = 0;
|
||||
virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) = 0;
|
||||
// Gets quality stats for the channel.
|
||||
virtual bool GetStats(VideoMediaInfo* info) = 0;
|
||||
// Send an intra frame to the receivers.
|
||||
@ -1169,7 +1175,7 @@ enum DataMessageType {
|
||||
struct ReceiveDataParams {
|
||||
// The in-packet stream indentifier.
|
||||
// For SCTP, this is really SID, not SSRC.
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
// The type of message (binary, text, or control).
|
||||
DataMessageType type;
|
||||
// A per-stream value incremented per packet in the stream.
|
||||
@ -1188,7 +1194,7 @@ struct ReceiveDataParams {
|
||||
struct SendDataParams {
|
||||
// The in-packet stream indentifier.
|
||||
// For SCTP, this is really SID, not SSRC.
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
// The type of message (binary, text, or control).
|
||||
DataMessageType type;
|
||||
|
||||
@ -1276,7 +1282,7 @@ class DataMediaChannel : public MediaChannel {
|
||||
// writable(bool)
|
||||
sigslot::signal1<bool> SignalReadyToSend;
|
||||
// Signal for notifying that the remote side has closed the DataChannel.
|
||||
sigslot::signal1<uint32> SignalStreamClosedRemotely;
|
||||
sigslot::signal1<uint32_t> SignalStreamClosedRemotely;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -95,7 +95,7 @@ void RtpDataMediaChannel::Construct(rtc::Timing* timing) {
|
||||
|
||||
|
||||
RtpDataMediaChannel::~RtpDataMediaChannel() {
|
||||
std::map<uint32, RtpClock*>::const_iterator iter;
|
||||
std::map<uint32_t, RtpClock*>::const_iterator iter;
|
||||
for (iter = rtp_clock_by_send_ssrc_.begin();
|
||||
iter != rtp_clock_by_send_ssrc_.end();
|
||||
++iter) {
|
||||
@ -103,10 +103,9 @@ RtpDataMediaChannel::~RtpDataMediaChannel() {
|
||||
}
|
||||
}
|
||||
|
||||
void RtpClock::Tick(
|
||||
double now, int* seq_num, uint32* timestamp) {
|
||||
void RtpClock::Tick(double now, int* seq_num, uint32_t* timestamp) {
|
||||
*seq_num = ++last_seq_num_;
|
||||
*timestamp = timestamp_offset_ + static_cast<uint32>(now * clockrate_);
|
||||
*timestamp = timestamp_offset_ + static_cast<uint32_t>(now * clockrate_);
|
||||
}
|
||||
|
||||
const DataCodec* FindUnknownCodec(const std::vector<DataCodec>& codecs) {
|
||||
@ -188,7 +187,7 @@ bool RtpDataMediaChannel::AddSendStream(const StreamParams& stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RtpDataMediaChannel::RemoveSendStream(uint32 ssrc) {
|
||||
bool RtpDataMediaChannel::RemoveSendStream(uint32_t ssrc) {
|
||||
if (!GetStreamBySsrc(send_streams_, ssrc)) {
|
||||
return false;
|
||||
}
|
||||
@ -217,7 +216,7 @@ bool RtpDataMediaChannel::AddRecvStream(const StreamParams& stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RtpDataMediaChannel::RemoveRecvStream(uint32 ssrc) {
|
||||
bool RtpDataMediaChannel::RemoveRecvStream(uint32_t ssrc) {
|
||||
RemoveStreamBySsrc(&recv_streams_, ssrc);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -66,21 +66,20 @@ class RtpDataEngine : public DataEngineInterface {
|
||||
// according to the clockrate.
|
||||
class RtpClock {
|
||||
public:
|
||||
RtpClock(int clockrate, uint16 first_seq_num, uint32 timestamp_offset)
|
||||
RtpClock(int clockrate, uint16_t first_seq_num, uint32_t timestamp_offset)
|
||||
: clockrate_(clockrate),
|
||||
last_seq_num_(first_seq_num),
|
||||
timestamp_offset_(timestamp_offset) {
|
||||
}
|
||||
timestamp_offset_(timestamp_offset) {}
|
||||
|
||||
// Given the current time (in number of seconds which must be
|
||||
// monotonically increasing), Return the next sequence number and
|
||||
// timestamp.
|
||||
void Tick(double now, int* seq_num, uint32* timestamp);
|
||||
void Tick(double now, int* seq_num, uint32_t* timestamp);
|
||||
|
||||
private:
|
||||
int clockrate_;
|
||||
uint16 last_seq_num_;
|
||||
uint32 timestamp_offset_;
|
||||
uint16_t last_seq_num_;
|
||||
uint32_t timestamp_offset_;
|
||||
};
|
||||
|
||||
class RtpDataMediaChannel : public DataMediaChannel {
|
||||
@ -99,9 +98,9 @@ class RtpDataMediaChannel : public DataMediaChannel {
|
||||
virtual bool SetSendParameters(const DataSendParameters& params);
|
||||
virtual bool SetRecvParameters(const DataRecvParameters& params);
|
||||
virtual bool AddSendStream(const StreamParams& sp);
|
||||
virtual bool RemoveSendStream(uint32 ssrc);
|
||||
virtual bool RemoveSendStream(uint32_t ssrc);
|
||||
virtual bool AddRecvStream(const StreamParams& sp);
|
||||
virtual bool RemoveRecvStream(uint32 ssrc);
|
||||
virtual bool RemoveRecvStream(uint32_t ssrc);
|
||||
virtual bool SetSend(bool send) {
|
||||
sending_ = send;
|
||||
return true;
|
||||
@ -133,7 +132,7 @@ class RtpDataMediaChannel : public DataMediaChannel {
|
||||
std::vector<DataCodec> recv_codecs_;
|
||||
std::vector<StreamParams> send_streams_;
|
||||
std::vector<StreamParams> recv_streams_;
|
||||
std::map<uint32, RtpClock*> rtp_clock_by_send_ssrc_;
|
||||
std::map<uint32_t, RtpClock*> rtp_clock_by_send_ssrc_;
|
||||
rtc::scoped_ptr<rtc::RateLimiter> send_limiter_;
|
||||
};
|
||||
|
||||
|
||||
@ -302,8 +302,8 @@ TEST_F(RtpDataMediaChannelTest, SendData) {
|
||||
cricket::RtpHeader header1 = GetSentDataHeader(1);
|
||||
EXPECT_EQ(header1.ssrc, 42U);
|
||||
EXPECT_EQ(header1.payload_type, 103);
|
||||
EXPECT_EQ(static_cast<uint16>(header0.seq_num + 1),
|
||||
static_cast<uint16>(header1.seq_num));
|
||||
EXPECT_EQ(static_cast<uint16_t>(header0.seq_num + 1),
|
||||
static_cast<uint16_t>(header1.seq_num));
|
||||
EXPECT_EQ(header0.timestamp + 180000, header1.timestamp);
|
||||
}
|
||||
|
||||
@ -362,11 +362,11 @@ TEST_F(RtpDataMediaChannelTest, SendDataMultipleClocks) {
|
||||
cricket::RtpHeader header1b = GetSentDataHeader(2);
|
||||
cricket::RtpHeader header2b = GetSentDataHeader(3);
|
||||
|
||||
EXPECT_EQ(static_cast<uint16>(header1a.seq_num + 1),
|
||||
static_cast<uint16>(header1b.seq_num));
|
||||
EXPECT_EQ(static_cast<uint16_t>(header1a.seq_num + 1),
|
||||
static_cast<uint16_t>(header1b.seq_num));
|
||||
EXPECT_EQ(header1a.timestamp + 90000, header1b.timestamp);
|
||||
EXPECT_EQ(static_cast<uint16>(header2a.seq_num + 1),
|
||||
static_cast<uint16>(header2b.seq_num));
|
||||
EXPECT_EQ(static_cast<uint16_t>(header2a.seq_num + 1),
|
||||
static_cast<uint16_t>(header2b.seq_num));
|
||||
EXPECT_EQ(header2a.timestamp + 180000, header2b.timestamp);
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ namespace cricket {
|
||||
|
||||
const char RtpDumpFileHeader::kFirstLine[] = "#!rtpplay1.0 0.0.0.0/0\n";
|
||||
|
||||
RtpDumpFileHeader::RtpDumpFileHeader(uint32 start_ms, uint32 s, uint16 p)
|
||||
RtpDumpFileHeader::RtpDumpFileHeader(uint32_t start_ms, uint32_t s, uint16_t p)
|
||||
: start_sec(start_ms / 1000),
|
||||
start_usec(start_ms % 1000 * 1000),
|
||||
source(s),
|
||||
@ -61,7 +61,7 @@ void RtpDumpFileHeader::WriteToByteBuffer(rtc::ByteBuffer* buf) {
|
||||
buf->WriteUInt16(padding);
|
||||
}
|
||||
|
||||
static const uint32 kDefaultTimeIncrease = 30;
|
||||
static const uint32_t kDefaultTimeIncrease = 30;
|
||||
|
||||
bool RtpDumpPacket::IsValidRtpPacket() const {
|
||||
return original_data_len >= data.size() &&
|
||||
@ -83,12 +83,12 @@ bool RtpDumpPacket::GetRtpSeqNum(int* seq_num) const {
|
||||
cricket::GetRtpSeqNum(&data[0], data.size(), seq_num);
|
||||
}
|
||||
|
||||
bool RtpDumpPacket::GetRtpTimestamp(uint32* ts) const {
|
||||
bool RtpDumpPacket::GetRtpTimestamp(uint32_t* ts) const {
|
||||
return IsValidRtpPacket() &&
|
||||
cricket::GetRtpTimestamp(&data[0], data.size(), ts);
|
||||
}
|
||||
|
||||
bool RtpDumpPacket::GetRtpSsrc(uint32* ssrc) const {
|
||||
bool RtpDumpPacket::GetRtpSsrc(uint32_t* ssrc) const {
|
||||
return IsValidRtpPacket() &&
|
||||
cricket::GetRtpSsrc(&data[0], data.size(), ssrc);
|
||||
}
|
||||
@ -107,7 +107,7 @@ bool RtpDumpPacket::GetRtcpType(int* type) const {
|
||||
// Implementation of RtpDumpReader.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RtpDumpReader::SetSsrc(uint32 ssrc) {
|
||||
void RtpDumpReader::SetSsrc(uint32_t ssrc) {
|
||||
ssrc_override_ = ssrc;
|
||||
}
|
||||
|
||||
@ -131,8 +131,8 @@ rtc::StreamResult RtpDumpReader::ReadPacket(RtpDumpPacket* packet) {
|
||||
return res;
|
||||
}
|
||||
rtc::ByteBuffer buf(header, sizeof(header));
|
||||
uint16 dump_packet_len;
|
||||
uint16 data_len;
|
||||
uint16_t dump_packet_len;
|
||||
uint16_t data_len;
|
||||
// Read the full length of the rtpdump packet, including the rtpdump header.
|
||||
buf.ReadUInt16(&dump_packet_len);
|
||||
packet->data.resize(dump_packet_len - sizeof(header));
|
||||
@ -175,8 +175,8 @@ rtc::StreamResult RtpDumpReader::ReadFileHeader() {
|
||||
res = stream_->ReadAll(header, sizeof(header), NULL, NULL);
|
||||
if (res == rtc::SR_SUCCESS) {
|
||||
rtc::ByteBuffer buf(header, sizeof(header));
|
||||
uint32 start_sec;
|
||||
uint32 start_usec;
|
||||
uint32_t start_sec;
|
||||
uint32_t start_usec;
|
||||
buf.ReadUInt32(&start_sec);
|
||||
buf.ReadUInt32(&start_usec);
|
||||
start_time_ms_ = start_sec * 1000 + start_usec / 1000;
|
||||
@ -258,7 +258,7 @@ void RtpDumpLoopReader::UpdateStreamStatistics(const RtpDumpPacket& packet) {
|
||||
// Get the RTP sequence number and timestamp of the dump packet.
|
||||
int rtp_seq_num = 0;
|
||||
packet.GetRtpSeqNum(&rtp_seq_num);
|
||||
uint32 rtp_timestamp = 0;
|
||||
uint32_t rtp_timestamp = 0;
|
||||
packet.GetRtpTimestamp(&rtp_timestamp);
|
||||
|
||||
// Set the timestamps and sequence number for the first dump packet.
|
||||
@ -301,7 +301,7 @@ void RtpDumpLoopReader::UpdateDumpPacket(RtpDumpPacket* packet) {
|
||||
// Get the old RTP sequence number and timestamp.
|
||||
int sequence = 0;
|
||||
packet->GetRtpSeqNum(&sequence);
|
||||
uint32 timestamp = 0;
|
||||
uint32_t timestamp = 0;
|
||||
packet->GetRtpTimestamp(×tamp);
|
||||
// Increase the RTP sequence number and timestamp.
|
||||
sequence += loop_count_ * rtp_seq_num_increase_;
|
||||
@ -331,7 +331,7 @@ void RtpDumpWriter::set_packet_filter(int filter) {
|
||||
LOG(LS_INFO) << "RtpDumpWriter set_packet_filter to " << packet_filter_;
|
||||
}
|
||||
|
||||
uint32 RtpDumpWriter::GetElapsedTime() const {
|
||||
uint32_t RtpDumpWriter::GetElapsedTime() const {
|
||||
return rtc::TimeSince(start_time_ms_);
|
||||
}
|
||||
|
||||
@ -349,8 +349,10 @@ rtc::StreamResult RtpDumpWriter::WriteFileHeader() {
|
||||
return WriteToStream(buf.Data(), buf.Length());
|
||||
}
|
||||
|
||||
rtc::StreamResult RtpDumpWriter::WritePacket(
|
||||
const void* data, size_t data_len, uint32 elapsed, bool rtcp) {
|
||||
rtc::StreamResult RtpDumpWriter::WritePacket(const void* data,
|
||||
size_t data_len,
|
||||
uint32_t elapsed,
|
||||
bool rtcp) {
|
||||
if (!stream_ || !data || 0 == data_len) return rtc::SR_ERROR;
|
||||
|
||||
rtc::StreamResult res = rtc::SR_SUCCESS;
|
||||
@ -371,9 +373,9 @@ rtc::StreamResult RtpDumpWriter::WritePacket(
|
||||
|
||||
// Write the dump packet header.
|
||||
rtc::ByteBuffer buf;
|
||||
buf.WriteUInt16(static_cast<uint16>(
|
||||
RtpDumpPacket::kHeaderLength + write_len));
|
||||
buf.WriteUInt16(static_cast<uint16>(rtcp ? 0 : data_len));
|
||||
buf.WriteUInt16(
|
||||
static_cast<uint16_t>(RtpDumpPacket::kHeaderLength + write_len));
|
||||
buf.WriteUInt16(static_cast<uint16_t>(rtcp ? 0 : data_len));
|
||||
buf.WriteUInt32(elapsed);
|
||||
res = WriteToStream(buf.Data(), buf.Length());
|
||||
if (res != rtc::SR_SUCCESS) {
|
||||
@ -410,10 +412,10 @@ size_t RtpDumpWriter::FilterPacket(const void* data, size_t data_len,
|
||||
|
||||
rtc::StreamResult RtpDumpWriter::WriteToStream(
|
||||
const void* data, size_t data_len) {
|
||||
uint32 before = rtc::Time();
|
||||
uint32_t before = rtc::Time();
|
||||
rtc::StreamResult result =
|
||||
stream_->WriteAll(data, data_len, NULL, NULL);
|
||||
uint32 delay = rtc::TimeSince(before);
|
||||
uint32_t delay = rtc::TimeSince(before);
|
||||
if (delay >= warn_slow_writes_delay_) {
|
||||
LOG(LS_WARNING) << "Slow RtpDump: took " << delay << "ms to write "
|
||||
<< data_len << " bytes.";
|
||||
|
||||
@ -56,24 +56,23 @@ enum RtpDumpPacketFilter {
|
||||
};
|
||||
|
||||
struct RtpDumpFileHeader {
|
||||
RtpDumpFileHeader(uint32 start_ms, uint32 s, uint16 p);
|
||||
RtpDumpFileHeader(uint32_t start_ms, uint32_t s, uint16_t p);
|
||||
void WriteToByteBuffer(rtc::ByteBuffer* buf);
|
||||
|
||||
static const char kFirstLine[];
|
||||
static const size_t kHeaderLength = 16;
|
||||
uint32 start_sec; // start of recording, the seconds part.
|
||||
uint32 start_usec; // start of recording, the microseconds part.
|
||||
uint32 source; // network source (multicast address).
|
||||
uint16 port; // UDP port.
|
||||
uint16 padding; // 2 bytes padding.
|
||||
uint32_t start_sec; // start of recording, the seconds part.
|
||||
uint32_t start_usec; // start of recording, the microseconds part.
|
||||
uint32_t source; // network source (multicast address).
|
||||
uint16_t port; // UDP port.
|
||||
uint16_t padding; // 2 bytes padding.
|
||||
};
|
||||
|
||||
struct RtpDumpPacket {
|
||||
RtpDumpPacket() {}
|
||||
|
||||
RtpDumpPacket(const void* d, size_t s, uint32 elapsed, bool rtcp)
|
||||
: elapsed_time(elapsed),
|
||||
original_data_len((rtcp) ? 0 : s) {
|
||||
RtpDumpPacket(const void* d, size_t s, uint32_t elapsed, bool rtcp)
|
||||
: elapsed_time(elapsed), original_data_len((rtcp) ? 0 : s) {
|
||||
data.resize(s);
|
||||
memcpy(&data[0], d, s);
|
||||
}
|
||||
@ -87,16 +86,16 @@ struct RtpDumpPacket {
|
||||
// packet. Return true and set the output parameter if successful.
|
||||
bool GetRtpPayloadType(int* pt) const;
|
||||
bool GetRtpSeqNum(int* seq_num) const;
|
||||
bool GetRtpTimestamp(uint32* ts) const;
|
||||
bool GetRtpSsrc(uint32* ssrc) const;
|
||||
bool GetRtpTimestamp(uint32_t* ts) const;
|
||||
bool GetRtpSsrc(uint32_t* ssrc) const;
|
||||
bool GetRtpHeaderLen(size_t* len) const;
|
||||
// Get the type of the RTCP packet. Return true and set the output parameter
|
||||
// if successful.
|
||||
bool GetRtcpType(int* type) const;
|
||||
|
||||
static const size_t kHeaderLength = 8;
|
||||
uint32 elapsed_time; // Milliseconds since the start of recording.
|
||||
std::vector<uint8> data; // The actual RTP or RTCP packet.
|
||||
uint32_t elapsed_time; // Milliseconds since the start of recording.
|
||||
std::vector<uint8_t> data; // The actual RTP or RTCP packet.
|
||||
size_t original_data_len; // The original length of the packet; may be
|
||||
// greater than data.size() if only part of the
|
||||
// packet was recorded.
|
||||
@ -114,7 +113,7 @@ class RtpDumpReader {
|
||||
virtual ~RtpDumpReader() {}
|
||||
|
||||
// Use the specified ssrc, rather than the ssrc from dump, for RTP packets.
|
||||
void SetSsrc(uint32 ssrc);
|
||||
void SetSsrc(uint32_t ssrc);
|
||||
virtual rtc::StreamResult ReadPacket(RtpDumpPacket* packet);
|
||||
|
||||
protected:
|
||||
@ -130,8 +129,8 @@ class RtpDumpReader {
|
||||
rtc::StreamInterface* stream_;
|
||||
bool file_header_read_;
|
||||
size_t first_line_and_file_header_len_;
|
||||
uint32 start_time_ms_;
|
||||
uint32 ssrc_override_;
|
||||
uint32_t start_time_ms_;
|
||||
uint32_t ssrc_override_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpReader);
|
||||
};
|
||||
@ -164,22 +163,22 @@ class RtpDumpLoopReader : public RtpDumpReader {
|
||||
// How much to increase the elapsed time, RTP sequence number, RTP timestampe
|
||||
// for each loop. They are calcualted with the variables below during the
|
||||
// first loop.
|
||||
uint32 elapsed_time_increases_;
|
||||
uint32_t elapsed_time_increases_;
|
||||
int rtp_seq_num_increase_;
|
||||
uint32 rtp_timestamp_increase_;
|
||||
uint32_t rtp_timestamp_increase_;
|
||||
// How many RTP packets and how many payload frames in the input stream. RTP
|
||||
// packets belong to the same frame have the same RTP timestamp, different
|
||||
// dump timestamp, and different RTP sequence number.
|
||||
uint32 packet_count_;
|
||||
uint32 frame_count_;
|
||||
uint32_t packet_count_;
|
||||
uint32_t frame_count_;
|
||||
// The elapsed time, RTP sequence number, and RTP timestamp of the first and
|
||||
// the previous dump packets in the input stream.
|
||||
uint32 first_elapsed_time_;
|
||||
uint32_t first_elapsed_time_;
|
||||
int first_rtp_seq_num_;
|
||||
uint32 first_rtp_timestamp_;
|
||||
uint32 prev_elapsed_time_;
|
||||
uint32_t first_rtp_timestamp_;
|
||||
uint32_t prev_elapsed_time_;
|
||||
int prev_rtp_seq_num_;
|
||||
uint32 prev_rtp_timestamp_;
|
||||
uint32_t prev_rtp_timestamp_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpLoopReader);
|
||||
};
|
||||
@ -202,7 +201,7 @@ class RtpDumpWriter {
|
||||
return WritePacket(&packet.data[0], packet.data.size(), packet.elapsed_time,
|
||||
packet.is_rtcp());
|
||||
}
|
||||
uint32 GetElapsedTime() const;
|
||||
uint32_t GetElapsedTime() const;
|
||||
|
||||
bool GetDumpSize(size_t* size) {
|
||||
// Note that we use GetPosition(), rather than GetSize(), to avoid flush the
|
||||
@ -214,17 +213,19 @@ class RtpDumpWriter {
|
||||
rtc::StreamResult WriteFileHeader();
|
||||
|
||||
private:
|
||||
rtc::StreamResult WritePacket(const void* data, size_t data_len,
|
||||
uint32 elapsed, bool rtcp);
|
||||
rtc::StreamResult WritePacket(const void* data,
|
||||
size_t data_len,
|
||||
uint32_t elapsed,
|
||||
bool rtcp);
|
||||
size_t FilterPacket(const void* data, size_t data_len, bool rtcp);
|
||||
rtc::StreamResult WriteToStream(const void* data, size_t data_len);
|
||||
|
||||
rtc::StreamInterface* stream_;
|
||||
int packet_filter_;
|
||||
bool file_header_written_;
|
||||
uint32 start_time_ms_; // Time when the record starts.
|
||||
uint32_t start_time_ms_; // Time when the record starts.
|
||||
// If writing to the stream takes longer than this many ms, log a warning.
|
||||
uint32 warn_slow_writes_delay_;
|
||||
uint32_t warn_slow_writes_delay_;
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpWriter);
|
||||
};
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
namespace cricket {
|
||||
|
||||
static const uint32 kTestSsrc = 1;
|
||||
static const uint32_t kTestSsrc = 1;
|
||||
|
||||
// Test that we read the correct header fields from the RTP/RTCP packet.
|
||||
TEST(RtpDumpTest, ReadRtpDumpPacket) {
|
||||
@ -46,8 +46,8 @@ TEST(RtpDumpTest, ReadRtpDumpPacket) {
|
||||
|
||||
int payload_type;
|
||||
int seq_num;
|
||||
uint32 ts;
|
||||
uint32 ssrc;
|
||||
uint32_t ts;
|
||||
uint32_t ssrc;
|
||||
int rtcp_type;
|
||||
EXPECT_FALSE(rtp_packet.is_rtcp());
|
||||
EXPECT_TRUE(rtp_packet.IsValidRtpPacket());
|
||||
@ -129,7 +129,7 @@ TEST(RtpDumpTest, WriteReadSameRtp) {
|
||||
RtpDumpReader reader(&stream);
|
||||
for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) {
|
||||
EXPECT_EQ(rtc::SR_SUCCESS, reader.ReadPacket(&packet));
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc));
|
||||
EXPECT_EQ(kTestSsrc, ssrc);
|
||||
}
|
||||
@ -139,13 +139,13 @@ TEST(RtpDumpTest, WriteReadSameRtp) {
|
||||
// Rewind the stream and read again with a specified ssrc.
|
||||
stream.Rewind();
|
||||
RtpDumpReader reader_w_ssrc(&stream);
|
||||
const uint32 send_ssrc = kTestSsrc + 1;
|
||||
const uint32_t send_ssrc = kTestSsrc + 1;
|
||||
reader_w_ssrc.SetSsrc(send_ssrc);
|
||||
for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) {
|
||||
EXPECT_EQ(rtc::SR_SUCCESS, reader_w_ssrc.ReadPacket(&packet));
|
||||
EXPECT_FALSE(packet.is_rtcp());
|
||||
EXPECT_EQ(packet.original_data_len, packet.data.size());
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc));
|
||||
EXPECT_EQ(send_ssrc, ssrc);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ bool GetUint8(const void* data, size_t offset, int* value) {
|
||||
if (!data || !value) {
|
||||
return false;
|
||||
}
|
||||
*value = *(static_cast<const uint8*>(data) + offset);
|
||||
*value = *(static_cast<const uint8_t*>(data) + offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,15 +50,15 @@ bool GetUint16(const void* data, size_t offset, int* value) {
|
||||
return false;
|
||||
}
|
||||
*value = static_cast<int>(
|
||||
rtc::GetBE16(static_cast<const uint8*>(data) + offset));
|
||||
rtc::GetBE16(static_cast<const uint8_t*>(data) + offset));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetUint32(const void* data, size_t offset, uint32* value) {
|
||||
bool GetUint32(const void* data, size_t offset, uint32_t* value) {
|
||||
if (!data || !value) {
|
||||
return false;
|
||||
}
|
||||
*value = rtc::GetBE32(static_cast<const uint8*>(data) + offset);
|
||||
*value = rtc::GetBE32(static_cast<const uint8_t*>(data) + offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,15 +74,15 @@ bool SetUint16(void* data, size_t offset, uint16_t value) {
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
rtc::SetBE16(static_cast<uint8*>(data) + offset, value);
|
||||
rtc::SetBE16(static_cast<uint8_t*>(data) + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetUint32(void* data, size_t offset, uint32 value) {
|
||||
bool SetUint32(void* data, size_t offset, uint32_t value) {
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
rtc::SetBE32(static_cast<uint8*>(data) + offset, value);
|
||||
rtc::SetBE32(static_cast<uint8_t*>(data) + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -111,14 +111,14 @@ bool GetRtpSeqNum(const void* data, size_t len, int* value) {
|
||||
return GetUint16(data, kRtpSeqNumOffset, value);
|
||||
}
|
||||
|
||||
bool GetRtpTimestamp(const void* data, size_t len, uint32* value) {
|
||||
bool GetRtpTimestamp(const void* data, size_t len, uint32_t* value) {
|
||||
if (len < kMinRtpPacketLen) {
|
||||
return false;
|
||||
}
|
||||
return GetUint32(data, kRtpTimestampOffset, value);
|
||||
}
|
||||
|
||||
bool GetRtpSsrc(const void* data, size_t len, uint32* value) {
|
||||
bool GetRtpSsrc(const void* data, size_t len, uint32_t* value) {
|
||||
if (len < kMinRtpPacketLen) {
|
||||
return false;
|
||||
}
|
||||
@ -127,15 +127,16 @@ bool GetRtpSsrc(const void* data, size_t len, uint32* value) {
|
||||
|
||||
bool GetRtpHeaderLen(const void* data, size_t len, size_t* value) {
|
||||
if (!data || len < kMinRtpPacketLen || !value) return false;
|
||||
const uint8* header = static_cast<const uint8*>(data);
|
||||
const uint8_t* header = static_cast<const uint8_t*>(data);
|
||||
// Get base header size + length of CSRCs (not counting extension yet).
|
||||
size_t header_size = kMinRtpPacketLen + (header[0] & 0xF) * sizeof(uint32);
|
||||
size_t header_size = kMinRtpPacketLen + (header[0] & 0xF) * sizeof(uint32_t);
|
||||
if (len < header_size) return false;
|
||||
// If there's an extension, read and add in the extension size.
|
||||
if (header[0] & 0x10) {
|
||||
if (len < header_size + sizeof(uint32)) return false;
|
||||
header_size += ((rtc::GetBE16(header + header_size + 2) + 1) *
|
||||
sizeof(uint32));
|
||||
if (len < header_size + sizeof(uint32_t))
|
||||
return false;
|
||||
header_size +=
|
||||
((rtc::GetBE16(header + header_size + 2) + 1) * sizeof(uint32_t));
|
||||
if (len < header_size) return false;
|
||||
}
|
||||
*value = header_size;
|
||||
@ -159,18 +160,18 @@ bool GetRtcpType(const void* data, size_t len, int* value) {
|
||||
// This method returns SSRC first of RTCP packet, except if packet is SDES.
|
||||
// TODO(mallinath) - Fully implement RFC 5506. This standard doesn't restrict
|
||||
// to send non-compound packets only to feedback messages.
|
||||
bool GetRtcpSsrc(const void* data, size_t len, uint32* value) {
|
||||
bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value) {
|
||||
// Packet should be at least of 8 bytes, to get SSRC from a RTCP packet.
|
||||
if (!data || len < kMinRtcpPacketLen + 4 || !value) return false;
|
||||
int pl_type;
|
||||
if (!GetRtcpType(data, len, &pl_type)) return false;
|
||||
// SDES packet parsing is not supported.
|
||||
if (pl_type == kRtcpTypeSDES) return false;
|
||||
*value = rtc::GetBE32(static_cast<const uint8*>(data) + 4);
|
||||
*value = rtc::GetBE32(static_cast<const uint8_t*>(data) + 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetRtpSsrc(void* data, size_t len, uint32 value) {
|
||||
bool SetRtpSsrc(void* data, size_t len, uint32_t value) {
|
||||
return SetUint32(data, kRtpSsrcOffset, value);
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ bool IsRtpPacket(const void* data, size_t len) {
|
||||
if (len < kMinRtpPacketLen)
|
||||
return false;
|
||||
|
||||
return (static_cast<const uint8*>(data)[0] >> 6) == kRtpVersion;
|
||||
return (static_cast<const uint8_t*>(data)[0] >> 6) == kRtpVersion;
|
||||
}
|
||||
|
||||
bool IsValidRtpPayloadType(int payload_type) {
|
||||
|
||||
@ -39,8 +39,8 @@ const size_t kMinRtcpPacketLen = 4;
|
||||
struct RtpHeader {
|
||||
int payload_type;
|
||||
int seq_num;
|
||||
uint32 timestamp;
|
||||
uint32 ssrc;
|
||||
uint32_t timestamp;
|
||||
uint32_t ssrc;
|
||||
};
|
||||
|
||||
enum RtcpTypes {
|
||||
@ -55,14 +55,14 @@ enum RtcpTypes {
|
||||
|
||||
bool GetRtpPayloadType(const void* data, size_t len, int* value);
|
||||
bool GetRtpSeqNum(const void* data, size_t len, int* value);
|
||||
bool GetRtpTimestamp(const void* data, size_t len, uint32* value);
|
||||
bool GetRtpSsrc(const void* data, size_t len, uint32* value);
|
||||
bool GetRtpTimestamp(const void* data, size_t len, uint32_t* value);
|
||||
bool GetRtpSsrc(const void* data, size_t len, uint32_t* value);
|
||||
bool GetRtpHeaderLen(const void* data, size_t len, size_t* value);
|
||||
bool GetRtcpType(const void* data, size_t len, int* value);
|
||||
bool GetRtcpSsrc(const void* data, size_t len, uint32* value);
|
||||
bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value);
|
||||
bool GetRtpHeader(const void* data, size_t len, RtpHeader* header);
|
||||
|
||||
bool SetRtpSsrc(void* data, size_t len, uint32 value);
|
||||
bool SetRtpSsrc(void* data, size_t len, uint32_t value);
|
||||
// Assumes version 2, no padding, no extensions, no csrcs.
|
||||
bool SetRtpHeader(void* data, size_t len, const RtpHeader& header);
|
||||
|
||||
|
||||
@ -88,11 +88,11 @@ TEST(RtpUtilsTest, GetRtp) {
|
||||
EXPECT_TRUE(GetRtpSeqNum(kPcmuFrame, sizeof(kPcmuFrame), &seq_num));
|
||||
EXPECT_EQ(1, seq_num);
|
||||
|
||||
uint32 ts;
|
||||
uint32_t ts;
|
||||
EXPECT_TRUE(GetRtpTimestamp(kPcmuFrame, sizeof(kPcmuFrame), &ts));
|
||||
EXPECT_EQ(0u, ts);
|
||||
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
EXPECT_TRUE(GetRtpSsrc(kPcmuFrame, sizeof(kPcmuFrame), &ssrc));
|
||||
EXPECT_EQ(1u, ssrc);
|
||||
|
||||
@ -157,7 +157,7 @@ TEST(RtpUtilsTest, GetRtcp) {
|
||||
|
||||
EXPECT_FALSE(GetRtcpType(kInvalidPacket, sizeof(kInvalidPacket), &pt));
|
||||
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpPliFeedbackPacket,
|
||||
sizeof(kNonCompoundRtcpPliFeedbackPacket),
|
||||
&ssrc));
|
||||
|
||||
@ -100,10 +100,10 @@ bool MediaStreams::RemoveDataStream(
|
||||
return RemoveStream(&data_, selector);
|
||||
}
|
||||
|
||||
static std::string SsrcsToString(const std::vector<uint32>& ssrcs) {
|
||||
static std::string SsrcsToString(const std::vector<uint32_t>& ssrcs) {
|
||||
std::ostringstream ost;
|
||||
ost << "ssrcs:[";
|
||||
for (std::vector<uint32>::const_iterator it = ssrcs.begin();
|
||||
for (std::vector<uint32_t>::const_iterator it = ssrcs.begin();
|
||||
it != ssrcs.end(); ++it) {
|
||||
if (it != ssrcs.begin()) {
|
||||
ost << ",";
|
||||
@ -161,7 +161,7 @@ std::string StreamParams::ToString() const {
|
||||
ost << "}";
|
||||
return ost.str();
|
||||
}
|
||||
void StreamParams::GetPrimarySsrcs(std::vector<uint32>* ssrcs) const {
|
||||
void StreamParams::GetPrimarySsrcs(std::vector<uint32_t>* ssrcs) const {
|
||||
const SsrcGroup* sim_group = get_ssrc_group(kSimSsrcGroupSemantics);
|
||||
if (sim_group == NULL) {
|
||||
ssrcs->push_back(first_ssrc());
|
||||
@ -172,10 +172,10 @@ void StreamParams::GetPrimarySsrcs(std::vector<uint32>* ssrcs) const {
|
||||
}
|
||||
}
|
||||
|
||||
void StreamParams::GetFidSsrcs(const std::vector<uint32>& primary_ssrcs,
|
||||
std::vector<uint32>* fid_ssrcs) const {
|
||||
void StreamParams::GetFidSsrcs(const std::vector<uint32_t>& primary_ssrcs,
|
||||
std::vector<uint32_t>* fid_ssrcs) const {
|
||||
for (size_t i = 0; i < primary_ssrcs.size(); ++i) {
|
||||
uint32 fid_ssrc;
|
||||
uint32_t fid_ssrc;
|
||||
if (GetFidSsrc(primary_ssrcs[i], &fid_ssrc)) {
|
||||
fid_ssrcs->push_back(fid_ssrc);
|
||||
}
|
||||
@ -183,14 +183,14 @@ void StreamParams::GetFidSsrcs(const std::vector<uint32>& primary_ssrcs,
|
||||
}
|
||||
|
||||
bool StreamParams::AddSecondarySsrc(const std::string& semantics,
|
||||
uint32 primary_ssrc,
|
||||
uint32 secondary_ssrc) {
|
||||
uint32_t primary_ssrc,
|
||||
uint32_t secondary_ssrc) {
|
||||
if (!has_ssrc(primary_ssrc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ssrcs.push_back(secondary_ssrc);
|
||||
std::vector<uint32> ssrc_vector;
|
||||
std::vector<uint32_t> ssrc_vector;
|
||||
ssrc_vector.push_back(primary_ssrc);
|
||||
ssrc_vector.push_back(secondary_ssrc);
|
||||
SsrcGroup ssrc_group = SsrcGroup(semantics, ssrc_vector);
|
||||
@ -199,8 +199,8 @@ bool StreamParams::AddSecondarySsrc(const std::string& semantics,
|
||||
}
|
||||
|
||||
bool StreamParams::GetSecondarySsrc(const std::string& semantics,
|
||||
uint32 primary_ssrc,
|
||||
uint32* secondary_ssrc) const {
|
||||
uint32_t primary_ssrc,
|
||||
uint32_t* secondary_ssrc) const {
|
||||
for (std::vector<SsrcGroup>::const_iterator it = ssrc_groups.begin();
|
||||
it != ssrc_groups.end(); ++it) {
|
||||
if (it->has_semantics(semantics) &&
|
||||
@ -226,8 +226,8 @@ bool IsOneSsrcStream(const StreamParams& sp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void RemoveFirst(std::list<uint32>* ssrcs, uint32 value) {
|
||||
std::list<uint32>::iterator it =
|
||||
static void RemoveFirst(std::list<uint32_t>* ssrcs, uint32_t value) {
|
||||
std::list<uint32_t>::iterator it =
|
||||
std::find(ssrcs->begin(), ssrcs->end(), value);
|
||||
if (it != ssrcs->end()) {
|
||||
ssrcs->erase(it);
|
||||
@ -242,7 +242,7 @@ bool IsSimulcastStream(const StreamParams& sp) {
|
||||
// Start with all StreamParams SSRCs. Remove simulcast SSRCs (from sg) and
|
||||
// RTX SSRCs. If we still have SSRCs left, we don't know what they're for.
|
||||
// Also we remove first-found SSRCs only. So duplicates should lead to errors.
|
||||
std::list<uint32> sp_ssrcs(sp.ssrcs.begin(), sp.ssrcs.end());
|
||||
std::list<uint32_t> sp_ssrcs(sp.ssrcs.begin(), sp.ssrcs.end());
|
||||
for (size_t i = 0; i < sg->ssrcs.size(); ++i) {
|
||||
RemoveFirst(&sp_ssrcs, sg->ssrcs[i]);
|
||||
}
|
||||
|
||||
@ -58,9 +58,8 @@ extern const char kFidSsrcGroupSemantics[];
|
||||
extern const char kSimSsrcGroupSemantics[];
|
||||
|
||||
struct SsrcGroup {
|
||||
SsrcGroup(const std::string& usage, const std::vector<uint32>& ssrcs)
|
||||
: semantics(usage), ssrcs(ssrcs) {
|
||||
}
|
||||
SsrcGroup(const std::string& usage, const std::vector<uint32_t>& ssrcs)
|
||||
: semantics(usage), ssrcs(ssrcs) {}
|
||||
|
||||
bool operator==(const SsrcGroup& other) const {
|
||||
return (semantics == other.semantics && ssrcs == other.ssrcs);
|
||||
@ -74,11 +73,11 @@ struct SsrcGroup {
|
||||
std::string ToString() const;
|
||||
|
||||
std::string semantics; // e.g FIX, FEC, SIM.
|
||||
std::vector<uint32> ssrcs; // SSRCs of this type.
|
||||
std::vector<uint32_t> ssrcs; // SSRCs of this type.
|
||||
};
|
||||
|
||||
struct StreamParams {
|
||||
static StreamParams CreateLegacy(uint32 ssrc) {
|
||||
static StreamParams CreateLegacy(uint32_t ssrc) {
|
||||
StreamParams stream;
|
||||
stream.ssrcs.push_back(ssrc);
|
||||
return stream;
|
||||
@ -98,7 +97,7 @@ struct StreamParams {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
uint32 first_ssrc() const {
|
||||
uint32_t first_ssrc() const {
|
||||
if (ssrcs.empty()) {
|
||||
return 0;
|
||||
}
|
||||
@ -108,12 +107,10 @@ struct StreamParams {
|
||||
bool has_ssrcs() const {
|
||||
return !ssrcs.empty();
|
||||
}
|
||||
bool has_ssrc(uint32 ssrc) const {
|
||||
bool has_ssrc(uint32_t ssrc) const {
|
||||
return std::find(ssrcs.begin(), ssrcs.end(), ssrc) != ssrcs.end();
|
||||
}
|
||||
void add_ssrc(uint32 ssrc) {
|
||||
ssrcs.push_back(ssrc);
|
||||
}
|
||||
void add_ssrc(uint32_t ssrc) { ssrcs.push_back(ssrc); }
|
||||
bool has_ssrc_groups() const {
|
||||
return !ssrc_groups.empty();
|
||||
}
|
||||
@ -132,25 +129,25 @@ struct StreamParams {
|
||||
|
||||
// Convenience function to add an FID ssrc for a primary_ssrc
|
||||
// that's already been added.
|
||||
inline bool AddFidSsrc(uint32 primary_ssrc, uint32 fid_ssrc) {
|
||||
inline bool AddFidSsrc(uint32_t primary_ssrc, uint32_t fid_ssrc) {
|
||||
return AddSecondarySsrc(kFidSsrcGroupSemantics, primary_ssrc, fid_ssrc);
|
||||
}
|
||||
|
||||
// Convenience function to lookup the FID ssrc for a primary_ssrc.
|
||||
// Returns false if primary_ssrc not found or FID not defined for it.
|
||||
inline bool GetFidSsrc(uint32 primary_ssrc, uint32* fid_ssrc) const {
|
||||
inline bool GetFidSsrc(uint32_t primary_ssrc, uint32_t* fid_ssrc) const {
|
||||
return GetSecondarySsrc(kFidSsrcGroupSemantics, primary_ssrc, fid_ssrc);
|
||||
}
|
||||
|
||||
// Convenience to get all the SIM SSRCs if there are SIM ssrcs, or
|
||||
// the first SSRC otherwise.
|
||||
void GetPrimarySsrcs(std::vector<uint32>* ssrcs) const;
|
||||
void GetPrimarySsrcs(std::vector<uint32_t>* ssrcs) const;
|
||||
|
||||
// Convenience to get all the FID SSRCs for the given primary ssrcs.
|
||||
// If a given primary SSRC does not have a FID SSRC, the list of FID
|
||||
// SSRCS will be smaller than the list of primary SSRCs.
|
||||
void GetFidSsrcs(const std::vector<uint32>& primary_ssrcs,
|
||||
std::vector<uint32>* fid_ssrcs) const;
|
||||
void GetFidSsrcs(const std::vector<uint32_t>& primary_ssrcs,
|
||||
std::vector<uint32_t>* fid_ssrcs) const;
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
@ -160,7 +157,7 @@ struct StreamParams {
|
||||
std::string groupid;
|
||||
// Unique per-groupid, not across all groupids
|
||||
std::string id;
|
||||
std::vector<uint32> ssrcs; // All SSRCs for this source
|
||||
std::vector<uint32_t> ssrcs; // All SSRCs for this source
|
||||
std::vector<SsrcGroup> ssrc_groups; // e.g. FID, FEC, SIM
|
||||
// Examples: "camera", "screencast"
|
||||
std::string type;
|
||||
@ -170,17 +167,17 @@ struct StreamParams {
|
||||
std::string sync_label; // Friendly name of cname.
|
||||
|
||||
private:
|
||||
bool AddSecondarySsrc(const std::string& semantics, uint32 primary_ssrc,
|
||||
uint32 secondary_ssrc);
|
||||
bool GetSecondarySsrc(const std::string& semantics, uint32 primary_ssrc,
|
||||
uint32* secondary_ssrc) const;
|
||||
bool AddSecondarySsrc(const std::string& semantics,
|
||||
uint32_t primary_ssrc,
|
||||
uint32_t secondary_ssrc);
|
||||
bool GetSecondarySsrc(const std::string& semantics,
|
||||
uint32_t primary_ssrc,
|
||||
uint32_t* secondary_ssrc) const;
|
||||
};
|
||||
|
||||
// A Stream can be selected by either groupid+id or ssrc.
|
||||
struct StreamSelector {
|
||||
explicit StreamSelector(uint32 ssrc) :
|
||||
ssrc(ssrc) {
|
||||
}
|
||||
explicit StreamSelector(uint32_t ssrc) : ssrc(ssrc) {}
|
||||
|
||||
StreamSelector(const std::string& groupid,
|
||||
const std::string& streamid) :
|
||||
@ -197,7 +194,7 @@ struct StreamSelector {
|
||||
}
|
||||
}
|
||||
|
||||
uint32 ssrc;
|
||||
uint32_t ssrc;
|
||||
std::string groupid;
|
||||
std::string streamid;
|
||||
};
|
||||
@ -284,7 +281,7 @@ const StreamParams* GetStream(const StreamParamsVec& streams,
|
||||
}
|
||||
|
||||
inline const StreamParams* GetStreamBySsrc(const StreamParamsVec& streams,
|
||||
uint32 ssrc) {
|
||||
uint32_t ssrc) {
|
||||
return GetStream(streams,
|
||||
[&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); });
|
||||
}
|
||||
@ -320,7 +317,7 @@ inline bool RemoveStream(StreamParamsVec* streams,
|
||||
return RemoveStream(streams,
|
||||
[&selector](const StreamParams& sp) { return selector.Matches(sp); });
|
||||
}
|
||||
inline bool RemoveStreamBySsrc(StreamParamsVec* streams, uint32 ssrc) {
|
||||
inline bool RemoveStreamBySsrc(StreamParamsVec* streams, uint32_t ssrc) {
|
||||
return RemoveStream(streams,
|
||||
[&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); });
|
||||
}
|
||||
|
||||
@ -29,15 +29,17 @@
|
||||
#include "talk/media/base/testutils.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
|
||||
static const uint32 kSsrcs1[] = {1};
|
||||
static const uint32 kSsrcs2[] = {1, 2};
|
||||
static const uint32 kSsrcs3[] = {1, 2, 3};
|
||||
static const uint32 kRtxSsrcs3[] = {4, 5, 6};
|
||||
static const uint32_t kSsrcs1[] = {1};
|
||||
static const uint32_t kSsrcs2[] = {1, 2};
|
||||
static const uint32_t kSsrcs3[] = {1, 2, 3};
|
||||
static const uint32_t kRtxSsrcs3[] = {4, 5, 6};
|
||||
|
||||
static cricket::StreamParams CreateStreamParamsWithSsrcGroup(
|
||||
const std::string& semantics, const uint32 ssrcs_in[], size_t len) {
|
||||
const std::string& semantics,
|
||||
const uint32_t ssrcs_in[],
|
||||
size_t len) {
|
||||
cricket::StreamParams stream;
|
||||
std::vector<uint32> ssrcs(ssrcs_in, ssrcs_in + len);
|
||||
std::vector<uint32_t> ssrcs(ssrcs_in, ssrcs_in + len);
|
||||
cricket::SsrcGroup sg(semantics, ssrcs);
|
||||
stream.ssrcs = ssrcs;
|
||||
stream.ssrc_groups.push_back(sg);
|
||||
@ -77,7 +79,7 @@ TEST(SsrcGroup, ToString) {
|
||||
}
|
||||
|
||||
TEST(StreamParams, CreateLegacy) {
|
||||
const uint32 ssrc = 7;
|
||||
const uint32_t ssrc = 7;
|
||||
cricket::StreamParams one_sp = cricket::StreamParams::CreateLegacy(ssrc);
|
||||
EXPECT_EQ(1U, one_sp.ssrcs.size());
|
||||
EXPECT_EQ(ssrc, one_sp.first_ssrc());
|
||||
@ -132,7 +134,7 @@ TEST(StreamParams, EqualNotEqual) {
|
||||
}
|
||||
|
||||
TEST(StreamParams, FidFunctions) {
|
||||
uint32 fid_ssrc;
|
||||
uint32_t fid_ssrc;
|
||||
|
||||
cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(1);
|
||||
EXPECT_FALSE(sp.AddFidSsrc(10, 20));
|
||||
@ -149,7 +151,7 @@ TEST(StreamParams, FidFunctions) {
|
||||
// Manually create SsrcGroup to test bounds-checking
|
||||
// in GetSecondarySsrc. We construct an invalid StreamParams
|
||||
// for this.
|
||||
std::vector<uint32> fid_vector;
|
||||
std::vector<uint32_t> fid_vector;
|
||||
fid_vector.push_back(13);
|
||||
cricket::SsrcGroup invalid_fid_group(cricket::kFidSsrcGroupSemantics,
|
||||
fid_vector);
|
||||
@ -165,9 +167,9 @@ TEST(StreamParams, GetPrimaryAndFidSsrcs) {
|
||||
sp.ssrcs.push_back(2);
|
||||
sp.ssrcs.push_back(3);
|
||||
|
||||
std::vector<uint32> primary_ssrcs;
|
||||
std::vector<uint32_t> primary_ssrcs;
|
||||
sp.GetPrimarySsrcs(&primary_ssrcs);
|
||||
std::vector<uint32> fid_ssrcs;
|
||||
std::vector<uint32_t> fid_ssrcs;
|
||||
sp.GetFidSsrcs(primary_ssrcs, &fid_ssrcs);
|
||||
ASSERT_EQ(1u, primary_ssrcs.size());
|
||||
EXPECT_EQ(1u, primary_ssrcs[0]);
|
||||
@ -272,7 +274,7 @@ TEST(StreamParams, TestIsSimulcastStream_InvalidStreams) {
|
||||
// stream3 has two SIM groups.
|
||||
cricket::StreamParams stream3 =
|
||||
cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs2));
|
||||
std::vector<uint32> sim_ssrcs = MAKE_VECTOR(kRtxSsrcs3);
|
||||
std::vector<uint32_t> sim_ssrcs = MAKE_VECTOR(kRtxSsrcs3);
|
||||
cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, sim_ssrcs);
|
||||
for (size_t i = 0; i < sim_ssrcs.size(); i++) {
|
||||
stream3.add_ssrc(sim_ssrcs[i]);
|
||||
|
||||
@ -47,8 +47,8 @@ namespace cricket {
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of RawRtpPacket
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
void RawRtpPacket::WriteToByteBuffer(
|
||||
uint32 in_ssrc, rtc::ByteBuffer *buf) const {
|
||||
void RawRtpPacket::WriteToByteBuffer(uint32_t in_ssrc,
|
||||
rtc::ByteBuffer* buf) const {
|
||||
if (!buf) return;
|
||||
|
||||
buf->WriteUInt8(ver_to_cc);
|
||||
@ -72,8 +72,10 @@ bool RawRtpPacket::ReadFromByteBuffer(rtc::ByteBuffer* buf) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool RawRtpPacket::SameExceptSeqNumTimestampSsrc(
|
||||
const RawRtpPacket& packet, uint16 seq, uint32 ts, uint32 ssc) const {
|
||||
bool RawRtpPacket::SameExceptSeqNumTimestampSsrc(const RawRtpPacket& packet,
|
||||
uint16_t seq,
|
||||
uint32_t ts,
|
||||
uint32_t ssc) const {
|
||||
return sequence_number == seq &&
|
||||
timestamp == ts &&
|
||||
ver_to_cc == packet.ver_to_cc &&
|
||||
@ -134,12 +136,14 @@ size_t RtpTestUtility::GetTestPacketCount() {
|
||||
ARRAY_SIZE(kTestRawRtcpPackets));
|
||||
}
|
||||
|
||||
bool RtpTestUtility::WriteTestPackets(
|
||||
size_t count, bool rtcp, uint32 rtp_ssrc, RtpDumpWriter* writer) {
|
||||
bool RtpTestUtility::WriteTestPackets(size_t count,
|
||||
bool rtcp,
|
||||
uint32_t rtp_ssrc,
|
||||
RtpDumpWriter* writer) {
|
||||
if (!writer || count > GetTestPacketCount()) return false;
|
||||
|
||||
bool result = true;
|
||||
uint32 elapsed_time_ms = 0;
|
||||
uint32_t elapsed_time_ms = 0;
|
||||
for (size_t i = 0; i < count && result; ++i) {
|
||||
rtc::ByteBuffer buf;
|
||||
if (rtcp) {
|
||||
@ -155,11 +159,12 @@ bool RtpTestUtility::WriteTestPackets(
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RtpTestUtility::VerifyTestPacketsFromStream(
|
||||
size_t count, rtc::StreamInterface* stream, uint32 ssrc) {
|
||||
bool RtpTestUtility::VerifyTestPacketsFromStream(size_t count,
|
||||
rtc::StreamInterface* stream,
|
||||
uint32_t ssrc) {
|
||||
if (!stream) return false;
|
||||
|
||||
uint32 prev_elapsed_time = 0;
|
||||
uint32_t prev_elapsed_time = 0;
|
||||
bool result = true;
|
||||
stream->Rewind();
|
||||
RtpDumpLoopReader reader(stream);
|
||||
@ -188,10 +193,10 @@ bool RtpTestUtility::VerifyTestPacketsFromStream(
|
||||
result &= rtp_packet.ReadFromByteBuffer(&buf);
|
||||
result &= rtp_packet.SameExceptSeqNumTimestampSsrc(
|
||||
kTestRawRtpPackets[index],
|
||||
static_cast<uint16>(kTestRawRtpPackets[index].sequence_number +
|
||||
loop * GetTestPacketCount()),
|
||||
static_cast<uint32>(kTestRawRtpPackets[index].timestamp +
|
||||
loop * kRtpTimestampIncrease),
|
||||
static_cast<uint16_t>(kTestRawRtpPackets[index].sequence_number +
|
||||
loop * GetTestPacketCount()),
|
||||
static_cast<uint32_t>(kTestRawRtpPackets[index].timestamp +
|
||||
loop * kRtpTimestampIncrease),
|
||||
ssrc);
|
||||
}
|
||||
}
|
||||
@ -271,7 +276,9 @@ std::string GetTestFilePath(const std::string& filename) {
|
||||
|
||||
// Loads the image with the specified prefix and size into |out|.
|
||||
bool LoadPlanarYuvTestImage(const std::string& prefix,
|
||||
int width, int height, uint8* out) {
|
||||
int width,
|
||||
int height,
|
||||
uint8_t* out) {
|
||||
std::stringstream ss;
|
||||
ss << prefix << "." << width << "x" << height << "_P420.yuv";
|
||||
|
||||
@ -289,8 +296,10 @@ bool LoadPlanarYuvTestImage(const std::string& prefix,
|
||||
|
||||
// Dumps the YUV image out to a file, for visual inspection.
|
||||
// PYUV tool can be used to view dump files.
|
||||
void DumpPlanarYuvTestImage(const std::string& prefix, const uint8* img,
|
||||
int w, int h) {
|
||||
void DumpPlanarYuvTestImage(const std::string& prefix,
|
||||
const uint8_t* img,
|
||||
int w,
|
||||
int h) {
|
||||
rtc::FileStream fs;
|
||||
char filename[256];
|
||||
rtc::sprintfn(filename, sizeof(filename), "%s.%dx%d_P420.yuv",
|
||||
@ -301,8 +310,10 @@ void DumpPlanarYuvTestImage(const std::string& prefix, const uint8* img,
|
||||
|
||||
// Dumps the ARGB image out to a file, for visual inspection.
|
||||
// ffplay tool can be used to view dump files.
|
||||
void DumpPlanarArgbTestImage(const std::string& prefix, const uint8* img,
|
||||
int w, int h) {
|
||||
void DumpPlanarArgbTestImage(const std::string& prefix,
|
||||
const uint8_t* img,
|
||||
int w,
|
||||
int h) {
|
||||
rtc::FileStream fs;
|
||||
char filename[256];
|
||||
rtc::sprintfn(filename, sizeof(filename), "%s.%dx%d_ARGB.raw",
|
||||
@ -312,12 +323,12 @@ void DumpPlanarArgbTestImage(const std::string& prefix, const uint8* img,
|
||||
}
|
||||
|
||||
bool VideoFrameEqual(const VideoFrame* frame0, const VideoFrame* frame1) {
|
||||
const uint8* y0 = frame0->GetYPlane();
|
||||
const uint8* u0 = frame0->GetUPlane();
|
||||
const uint8* v0 = frame0->GetVPlane();
|
||||
const uint8* y1 = frame1->GetYPlane();
|
||||
const uint8* u1 = frame1->GetUPlane();
|
||||
const uint8* v1 = frame1->GetVPlane();
|
||||
const uint8_t* y0 = frame0->GetYPlane();
|
||||
const uint8_t* u0 = frame0->GetUPlane();
|
||||
const uint8_t* v0 = frame0->GetVPlane();
|
||||
const uint8_t* y1 = frame1->GetYPlane();
|
||||
const uint8_t* u1 = frame1->GetUPlane();
|
||||
const uint8_t* v1 = frame1->GetVPlane();
|
||||
|
||||
for (size_t i = 0; i < frame0->GetHeight(); ++i) {
|
||||
if (0 != memcmp(y0, y1, frame0->GetWidth())) {
|
||||
@ -344,7 +355,8 @@ bool VideoFrameEqual(const VideoFrame* frame0, const VideoFrame* frame1) {
|
||||
}
|
||||
|
||||
cricket::StreamParams CreateSimStreamParams(
|
||||
const std::string& cname, const std::vector<uint32>& ssrcs) {
|
||||
const std::string& cname,
|
||||
const std::vector<uint32_t>& ssrcs) {
|
||||
cricket::StreamParams sp;
|
||||
cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, ssrcs);
|
||||
sp.ssrcs = ssrcs;
|
||||
@ -355,12 +367,13 @@ cricket::StreamParams CreateSimStreamParams(
|
||||
|
||||
// There should be an rtx_ssrc per ssrc.
|
||||
cricket::StreamParams CreateSimWithRtxStreamParams(
|
||||
const std::string& cname, const std::vector<uint32>& ssrcs,
|
||||
const std::vector<uint32>& rtx_ssrcs) {
|
||||
const std::string& cname,
|
||||
const std::vector<uint32_t>& ssrcs,
|
||||
const std::vector<uint32_t>& rtx_ssrcs) {
|
||||
cricket::StreamParams sp = CreateSimStreamParams(cname, ssrcs);
|
||||
for (size_t i = 0; i < ssrcs.size(); ++i) {
|
||||
sp.ssrcs.push_back(rtx_ssrcs[i]);
|
||||
std::vector<uint32> fid_ssrcs;
|
||||
std::vector<uint32_t> fid_ssrcs;
|
||||
fid_ssrcs.push_back(ssrcs[i]);
|
||||
fid_ssrcs.push_back(rtx_ssrcs[i]);
|
||||
cricket::SsrcGroup fid_group(cricket::kFidSsrcGroupSemantics, fid_ssrcs);
|
||||
|
||||
@ -61,20 +61,22 @@ class RtpDumpWriter;
|
||||
class VideoFrame;
|
||||
|
||||
struct RawRtpPacket {
|
||||
void WriteToByteBuffer(uint32 in_ssrc, rtc::ByteBuffer* buf) const;
|
||||
void WriteToByteBuffer(uint32_t in_ssrc, rtc::ByteBuffer* buf) const;
|
||||
bool ReadFromByteBuffer(rtc::ByteBuffer* buf);
|
||||
// Check if this packet is the same as the specified packet except the
|
||||
// sequence number and timestamp, which should be the same as the specified
|
||||
// parameters.
|
||||
bool SameExceptSeqNumTimestampSsrc(
|
||||
const RawRtpPacket& packet, uint16 seq, uint32 ts, uint32 ssc) const;
|
||||
bool SameExceptSeqNumTimestampSsrc(const RawRtpPacket& packet,
|
||||
uint16_t seq,
|
||||
uint32_t ts,
|
||||
uint32_t ssc) const;
|
||||
int size() const { return 28; }
|
||||
|
||||
uint8 ver_to_cc;
|
||||
uint8 m_to_pt;
|
||||
uint16 sequence_number;
|
||||
uint32 timestamp;
|
||||
uint32 ssrc;
|
||||
uint8_t ver_to_cc;
|
||||
uint8_t m_to_pt;
|
||||
uint16_t sequence_number;
|
||||
uint32_t timestamp;
|
||||
uint32_t ssrc;
|
||||
char payload[16];
|
||||
};
|
||||
|
||||
@ -83,9 +85,9 @@ struct RawRtcpPacket {
|
||||
bool ReadFromByteBuffer(rtc::ByteBuffer* buf);
|
||||
bool EqualsTo(const RawRtcpPacket& packet) const;
|
||||
|
||||
uint8 ver_to_count;
|
||||
uint8 type;
|
||||
uint16 length;
|
||||
uint8_t ver_to_count;
|
||||
uint8_t type;
|
||||
uint16_t length;
|
||||
char payload[16];
|
||||
};
|
||||
|
||||
@ -96,26 +98,29 @@ class RtpTestUtility {
|
||||
// Write the first count number of kTestRawRtcpPackets or kTestRawRtpPackets,
|
||||
// depending on the flag rtcp. If it is RTP, use the specified SSRC. Return
|
||||
// true if successful.
|
||||
static bool WriteTestPackets(
|
||||
size_t count, bool rtcp, uint32 rtp_ssrc, RtpDumpWriter* writer);
|
||||
static bool WriteTestPackets(size_t count,
|
||||
bool rtcp,
|
||||
uint32_t rtp_ssrc,
|
||||
RtpDumpWriter* writer);
|
||||
|
||||
// Loop read the first count number of packets from the specified stream.
|
||||
// Verify the elapsed time of the dump packets increase monotonically. If the
|
||||
// stream is a RTP stream, verify the RTP sequence number, timestamp, and
|
||||
// payload. If the stream is a RTCP stream, verify the RTCP header and
|
||||
// payload.
|
||||
static bool VerifyTestPacketsFromStream(
|
||||
size_t count, rtc::StreamInterface* stream, uint32 ssrc);
|
||||
static bool VerifyTestPacketsFromStream(size_t count,
|
||||
rtc::StreamInterface* stream,
|
||||
uint32_t ssrc);
|
||||
|
||||
// Verify the dump packet is the same as the raw RTP packet.
|
||||
static bool VerifyPacket(const RtpDumpPacket* dump,
|
||||
const RawRtpPacket* raw,
|
||||
bool header_only);
|
||||
|
||||
static const uint32 kDefaultSsrc = 1;
|
||||
static const uint32 kRtpTimestampIncrease = 90;
|
||||
static const uint32 kDefaultTimeIncrease = 30;
|
||||
static const uint32 kElapsedTimeInterval = 10;
|
||||
static const uint32_t kDefaultSsrc = 1;
|
||||
static const uint32_t kRtpTimestampIncrease = 90;
|
||||
static const uint32_t kDefaultTimeIncrease = 30;
|
||||
static const uint32_t kElapsedTimeInterval = 10;
|
||||
static const RawRtpPacket kTestRawRtpPackets[];
|
||||
static const RawRtcpPacket kTestRawRtcpPackets[];
|
||||
|
||||
@ -130,10 +135,10 @@ class VideoCapturerListener : public sigslot::has_slots<> {
|
||||
|
||||
CaptureState last_capture_state() const { return last_capture_state_; }
|
||||
int frame_count() const { return frame_count_; }
|
||||
uint32 frame_fourcc() const { return frame_fourcc_; }
|
||||
uint32_t frame_fourcc() const { return frame_fourcc_; }
|
||||
int frame_width() const { return frame_width_; }
|
||||
int frame_height() const { return frame_height_; }
|
||||
uint32 frame_size() const { return frame_size_; }
|
||||
uint32_t frame_size() const { return frame_size_; }
|
||||
bool resolution_changed() const { return resolution_changed_; }
|
||||
|
||||
void OnStateChange(VideoCapturer* capturer, CaptureState state);
|
||||
@ -142,38 +147,38 @@ class VideoCapturerListener : public sigslot::has_slots<> {
|
||||
private:
|
||||
CaptureState last_capture_state_;
|
||||
int frame_count_;
|
||||
uint32 frame_fourcc_;
|
||||
uint32_t frame_fourcc_;
|
||||
int frame_width_;
|
||||
int frame_height_;
|
||||
uint32 frame_size_;
|
||||
uint32_t frame_size_;
|
||||
bool resolution_changed_;
|
||||
};
|
||||
|
||||
class ScreencastEventCatcher : public sigslot::has_slots<> {
|
||||
public:
|
||||
ScreencastEventCatcher() : ssrc_(0), ev_(rtc::WE_RESIZE) { }
|
||||
uint32 ssrc() const { return ssrc_; }
|
||||
uint32_t ssrc() const { return ssrc_; }
|
||||
rtc::WindowEvent event() const { return ev_; }
|
||||
void OnEvent(uint32 ssrc, rtc::WindowEvent ev) {
|
||||
void OnEvent(uint32_t ssrc, rtc::WindowEvent ev) {
|
||||
ssrc_ = ssrc;
|
||||
ev_ = ev;
|
||||
}
|
||||
private:
|
||||
uint32 ssrc_;
|
||||
uint32_t ssrc_;
|
||||
rtc::WindowEvent ev_;
|
||||
};
|
||||
|
||||
class VideoMediaErrorCatcher : public sigslot::has_slots<> {
|
||||
public:
|
||||
VideoMediaErrorCatcher() : ssrc_(0), error_(VideoMediaChannel::ERROR_NONE) { }
|
||||
uint32 ssrc() const { return ssrc_; }
|
||||
uint32_t ssrc() const { return ssrc_; }
|
||||
VideoMediaChannel::Error error() const { return error_; }
|
||||
void OnError(uint32 ssrc, VideoMediaChannel::Error error) {
|
||||
void OnError(uint32_t ssrc, VideoMediaChannel::Error error) {
|
||||
ssrc_ = ssrc;
|
||||
error_ = error;
|
||||
}
|
||||
private:
|
||||
uint32 ssrc_;
|
||||
uint32_t ssrc_;
|
||||
VideoMediaChannel::Error error_;
|
||||
};
|
||||
|
||||
@ -183,28 +188,35 @@ std::string GetTestFilePath(const std::string& filename);
|
||||
// PSNR formula: psnr = 10 * log10 (Peak Signal^2 / mse)
|
||||
// sse is set to a small number for identical frames or sse == 0
|
||||
static inline double ComputePSNR(double sse, double count) {
|
||||
return libyuv::SumSquareErrorToPsnr(static_cast<uint64>(sse),
|
||||
static_cast<uint64>(count));
|
||||
return libyuv::SumSquareErrorToPsnr(static_cast<uint64_t>(sse),
|
||||
static_cast<uint64_t>(count));
|
||||
}
|
||||
|
||||
static inline double ComputeSumSquareError(const uint8 *org, const uint8 *rec,
|
||||
static inline double ComputeSumSquareError(const uint8_t* org,
|
||||
const uint8_t* rec,
|
||||
int size) {
|
||||
return static_cast<double>(libyuv::ComputeSumSquareError(org, rec, size));
|
||||
}
|
||||
|
||||
// Loads the image with the specified prefix and size into |out|.
|
||||
bool LoadPlanarYuvTestImage(const std::string& prefix,
|
||||
int width, int height, uint8* out);
|
||||
int width,
|
||||
int height,
|
||||
uint8_t* out);
|
||||
|
||||
// Dumps the YUV image out to a file, for visual inspection.
|
||||
// PYUV tool can be used to view dump files.
|
||||
void DumpPlanarYuvTestImage(const std::string& prefix, const uint8* img,
|
||||
int w, int h);
|
||||
void DumpPlanarYuvTestImage(const std::string& prefix,
|
||||
const uint8_t* img,
|
||||
int w,
|
||||
int h);
|
||||
|
||||
// Dumps the ARGB image out to a file, for visual inspection.
|
||||
// ffplay tool can be used to view dump files.
|
||||
void DumpPlanarArgbTestImage(const std::string& prefix, const uint8* img,
|
||||
int w, int h);
|
||||
void DumpPlanarArgbTestImage(const std::string& prefix,
|
||||
const uint8_t* img,
|
||||
int w,
|
||||
int h);
|
||||
|
||||
// Compare two I420 frames.
|
||||
bool VideoFrameEqual(const VideoFrame* frame0, const VideoFrame* frame1);
|
||||
@ -222,13 +234,14 @@ bool ContainsMatchingCodec(const std::vector<C>& codecs, const C& codec) {
|
||||
}
|
||||
|
||||
// Create Simulcast StreamParams with given |ssrcs| and |cname|.
|
||||
cricket::StreamParams CreateSimStreamParams(
|
||||
const std::string& cname, const std::vector<uint32>& ssrcs);
|
||||
cricket::StreamParams CreateSimStreamParams(const std::string& cname,
|
||||
const std::vector<uint32_t>& ssrcs);
|
||||
// Create Simulcast stream with given |ssrcs| and |rtx_ssrcs|.
|
||||
// The number of |rtx_ssrcs| must match number of |ssrcs|.
|
||||
cricket::StreamParams CreateSimWithRtxStreamParams(
|
||||
const std::string& cname, const std::vector<uint32>& ssrcs,
|
||||
const std::vector<uint32>& rtx_ssrcs);
|
||||
const std::string& cname,
|
||||
const std::vector<uint32_t>& ssrcs,
|
||||
const std::vector<uint32_t>& rtx_ssrcs);
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
|
||||
@ -182,7 +182,7 @@ VideoAdapter::~VideoAdapter() {
|
||||
|
||||
void VideoAdapter::SetInputFormat(const VideoFormat& format) {
|
||||
rtc::CritScope cs(&critical_section_);
|
||||
int64 old_input_interval = input_format_.interval;
|
||||
int64_t old_input_interval = input_format_.interval;
|
||||
input_format_ = format;
|
||||
output_format_.interval =
|
||||
std::max(output_format_.interval, input_format_.interval);
|
||||
@ -223,7 +223,7 @@ void CoordinatedVideoAdapter::set_cpu_smoothing(bool enable) {
|
||||
|
||||
void VideoAdapter::SetOutputFormat(const VideoFormat& format) {
|
||||
rtc::CritScope cs(&critical_section_);
|
||||
int64 old_output_interval = output_format_.interval;
|
||||
int64_t old_output_interval = output_format_.interval;
|
||||
output_format_ = format;
|
||||
output_num_pixels_ = output_format_.width * output_format_.height;
|
||||
output_format_.interval =
|
||||
|
||||
@ -88,7 +88,7 @@ class VideoAdapter {
|
||||
int adaption_changes_; // Number of changes in scale factor.
|
||||
size_t previous_width_; // Previous adapter output width.
|
||||
size_t previous_height_; // Previous adapter output height.
|
||||
int64 interval_next_frame_;
|
||||
int64_t interval_next_frame_;
|
||||
// The critical section to protect the above variables.
|
||||
rtc::CriticalSection critical_section_;
|
||||
|
||||
@ -190,7 +190,7 @@ class CoordinatedVideoAdapter
|
||||
// Video formats that the server view requests, the CPU wants, and the encoder
|
||||
// wants respectively. The adapted output format is the minimum of these.
|
||||
int view_desired_num_pixels_;
|
||||
int64 view_desired_interval_;
|
||||
int64_t view_desired_interval_;
|
||||
int encoder_desired_num_pixels_;
|
||||
int cpu_desired_num_pixels_;
|
||||
CoordinatedVideoAdapter::AdaptReason adapt_reason_;
|
||||
|
||||
4
talk/media/base/videoadapter_unittest.cc
Executable file → Normal file
4
talk/media/base/videoadapter_unittest.cc
Executable file → Normal file
@ -42,8 +42,8 @@
|
||||
namespace cricket {
|
||||
|
||||
namespace {
|
||||
static const uint32 kWaitTimeout = 3000U; // 3 seconds.
|
||||
static const uint32 kShortWaitTimeout = 1000U; // 1 second.
|
||||
static const uint32_t kWaitTimeout = 3000U; // 3 seconds.
|
||||
static const uint32_t kShortWaitTimeout = 1000U; // 1 second.
|
||||
void UpdateCpuLoad(CoordinatedVideoAdapter* adapter,
|
||||
int current_cpus, int max_cpus, float process_load, float system_load) {
|
||||
adapter->set_cpu_load_min_samples(1);
|
||||
|
||||
@ -58,7 +58,7 @@ enum {
|
||||
MSG_STATE_CHANGE
|
||||
};
|
||||
|
||||
static const int64 kMaxDistance = ~(static_cast<int64>(1) << 63);
|
||||
static const int64_t kMaxDistance = ~(static_cast<int64_t>(1) << 63);
|
||||
#ifdef LINUX
|
||||
static const int kYU12Penalty = 16; // Needs to be higher than MJPG index.
|
||||
#endif
|
||||
@ -86,7 +86,7 @@ CapturedFrame::CapturedFrame()
|
||||
data(NULL) {}
|
||||
|
||||
// TODO(fbarchard): Remove this function once lmimediaengine stops using it.
|
||||
bool CapturedFrame::GetDataSize(uint32* size) const {
|
||||
bool CapturedFrame::GetDataSize(uint32_t* size) const {
|
||||
if (!size || data_size == CapturedFrame::kUnknownDataSize) {
|
||||
return false;
|
||||
}
|
||||
@ -275,11 +275,11 @@ bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format,
|
||||
return false;
|
||||
}
|
||||
LOG(LS_INFO) << " Capture Requested " << format.ToString();
|
||||
int64 best_distance = kMaxDistance;
|
||||
int64_t best_distance = kMaxDistance;
|
||||
std::vector<VideoFormat>::const_iterator best = supported_formats->end();
|
||||
std::vector<VideoFormat>::const_iterator i;
|
||||
for (i = supported_formats->begin(); i != supported_formats->end(); ++i) {
|
||||
int64 distance = GetFormatDistance(format, *i);
|
||||
int64_t distance = GetFormatDistance(format, *i);
|
||||
// TODO(fbarchard): Reduce to LS_VERBOSE if/when camera capture is
|
||||
// relatively bug free.
|
||||
LOG(LS_INFO) << " Supported " << i->ToString() << " distance " << distance;
|
||||
@ -361,7 +361,7 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
}
|
||||
|
||||
// Use a temporary buffer to scale
|
||||
rtc::scoped_ptr<uint8[]> scale_buffer;
|
||||
rtc::scoped_ptr<uint8_t[]> scale_buffer;
|
||||
|
||||
if (IsScreencast()) {
|
||||
int scaled_width, scaled_height;
|
||||
@ -390,16 +390,15 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
CapturedFrame* modified_frame =
|
||||
const_cast<CapturedFrame*>(captured_frame);
|
||||
const int modified_frame_size = scaled_width * scaled_height * 4;
|
||||
scale_buffer.reset(new uint8[modified_frame_size]);
|
||||
scale_buffer.reset(new uint8_t[modified_frame_size]);
|
||||
// Compute new width such that width * height is less than maximum but
|
||||
// maintains original captured frame aspect ratio.
|
||||
// Round down width to multiple of 4 so odd width won't round up beyond
|
||||
// maximum, and so chroma channel is even width to simplify spatial
|
||||
// resampling.
|
||||
libyuv::ARGBScale(reinterpret_cast<const uint8*>(captured_frame->data),
|
||||
libyuv::ARGBScale(reinterpret_cast<const uint8_t*>(captured_frame->data),
|
||||
captured_frame->width * 4, captured_frame->width,
|
||||
captured_frame->height,
|
||||
scale_buffer.get(),
|
||||
captured_frame->height, scale_buffer.get(),
|
||||
scaled_width * 4, scaled_width, scaled_height,
|
||||
libyuv::kFilterBilinear);
|
||||
modified_frame->width = scaled_width;
|
||||
@ -416,7 +415,7 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
// TODO(fbarchard): Avoid scale and convert if muted.
|
||||
// Temporary buffer is scoped here so it will persist until i420_frame.Init()
|
||||
// makes a copy of the frame, converting to I420.
|
||||
rtc::scoped_ptr<uint8[]> temp_buffer;
|
||||
rtc::scoped_ptr<uint8_t[]> temp_buffer;
|
||||
// YUY2 can be scaled vertically using an ARGB scaler. Aspect ratio is only
|
||||
// a problem on OSX. OSX always converts webcams to YUY2 or UYVY.
|
||||
bool can_scale =
|
||||
@ -450,26 +449,26 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
scaled_height_ = scaled_height;
|
||||
}
|
||||
const int modified_frame_size = scaled_width * scaled_height * kYuy2Bpp;
|
||||
uint8* temp_buffer_data;
|
||||
uint8_t* temp_buffer_data;
|
||||
// Pixels are wide and short; Increasing height. Requires temporary buffer.
|
||||
if (scaled_height > captured_frame->height) {
|
||||
temp_buffer.reset(new uint8[modified_frame_size]);
|
||||
temp_buffer.reset(new uint8_t[modified_frame_size]);
|
||||
temp_buffer_data = temp_buffer.get();
|
||||
} else {
|
||||
// Pixels are narrow and tall; Decreasing height. Scale will be done
|
||||
// in place.
|
||||
temp_buffer_data = reinterpret_cast<uint8*>(captured_frame->data);
|
||||
temp_buffer_data = reinterpret_cast<uint8_t*>(captured_frame->data);
|
||||
}
|
||||
|
||||
// Use ARGBScaler to vertically scale the YUY2 image, adjusting for 16 bpp.
|
||||
libyuv::ARGBScale(reinterpret_cast<const uint8*>(captured_frame->data),
|
||||
libyuv::ARGBScale(reinterpret_cast<const uint8_t*>(captured_frame->data),
|
||||
captured_frame->width * kYuy2Bpp, // Stride for YUY2.
|
||||
captured_frame->width * kYuy2Bpp / kArgbBpp, // Width.
|
||||
abs(captured_frame->height), // Height.
|
||||
abs(captured_frame->height), // Height.
|
||||
temp_buffer_data,
|
||||
scaled_width * kYuy2Bpp, // Stride for YUY2.
|
||||
scaled_width * kYuy2Bpp, // Stride for YUY2.
|
||||
scaled_width * kYuy2Bpp / kArgbBpp, // Width.
|
||||
abs(scaled_height), // New height.
|
||||
abs(scaled_height), // New height.
|
||||
libyuv::kFilterBilinear);
|
||||
modified_frame->width = scaled_width;
|
||||
modified_frame->height = scaled_height;
|
||||
@ -589,16 +588,16 @@ void VideoCapturer::OnMessage(rtc::Message* message) {
|
||||
// 3) Framerate closeness. If not same, we prefer faster.
|
||||
// 4) Compression. If desired format has a specific fourcc, we need exact match;
|
||||
// otherwise, we use preference.
|
||||
int64 VideoCapturer::GetFormatDistance(const VideoFormat& desired,
|
||||
const VideoFormat& supported) {
|
||||
int64 distance = kMaxDistance;
|
||||
int64_t VideoCapturer::GetFormatDistance(const VideoFormat& desired,
|
||||
const VideoFormat& supported) {
|
||||
int64_t distance = kMaxDistance;
|
||||
|
||||
// Check fourcc.
|
||||
uint32 supported_fourcc = CanonicalFourCC(supported.fourcc);
|
||||
int64 delta_fourcc = kMaxDistance;
|
||||
uint32_t supported_fourcc = CanonicalFourCC(supported.fourcc);
|
||||
int64_t delta_fourcc = kMaxDistance;
|
||||
if (FOURCC_ANY == desired.fourcc) {
|
||||
// Any fourcc is OK for the desired. Use preference to find best fourcc.
|
||||
std::vector<uint32> preferred_fourccs;
|
||||
std::vector<uint32_t> preferred_fourccs;
|
||||
if (!GetPreferredFourccs(&preferred_fourccs)) {
|
||||
return distance;
|
||||
}
|
||||
@ -629,15 +628,15 @@ int64 VideoCapturer::GetFormatDistance(const VideoFormat& desired,
|
||||
// Check resolution and fps.
|
||||
int desired_width = desired.width;
|
||||
int desired_height = desired.height;
|
||||
int64 delta_w = supported.width - desired_width;
|
||||
int64_t delta_w = supported.width - desired_width;
|
||||
float supported_fps = VideoFormat::IntervalToFpsFloat(supported.interval);
|
||||
float delta_fps =
|
||||
supported_fps - VideoFormat::IntervalToFpsFloat(desired.interval);
|
||||
// Check height of supported height compared to height we would like it to be.
|
||||
int64 aspect_h =
|
||||
desired_width ? supported.width * desired_height / desired_width
|
||||
: desired_height;
|
||||
int64 delta_h = supported.height - aspect_h;
|
||||
int64_t aspect_h = desired_width
|
||||
? supported.width * desired_height / desired_width
|
||||
: desired_height;
|
||||
int64_t delta_h = supported.height - aspect_h;
|
||||
|
||||
distance = 0;
|
||||
// Set high penalty if the supported format is lower than the desired format.
|
||||
@ -664,12 +663,12 @@ int64 VideoCapturer::GetFormatDistance(const VideoFormat& desired,
|
||||
VideoFormat::IntervalToFpsFloat(desired.interval) * 23.f / 30.f;
|
||||
delta_fps = -delta_fps;
|
||||
if (supported_fps < min_desirable_fps) {
|
||||
distance |= static_cast<int64>(1) << 62;
|
||||
distance |= static_cast<int64_t>(1) << 62;
|
||||
} else {
|
||||
distance |= static_cast<int64>(1) << 15;
|
||||
distance |= static_cast<int64_t>(1) << 15;
|
||||
}
|
||||
}
|
||||
int64 idelta_fps = static_cast<int>(delta_fps);
|
||||
int64_t idelta_fps = static_cast<int>(delta_fps);
|
||||
|
||||
// 12 bits for width and height and 8 bits for fps and fourcc.
|
||||
distance |=
|
||||
|
||||
@ -68,15 +68,15 @@ enum CaptureState {
|
||||
class VideoFrame;
|
||||
|
||||
struct CapturedFrame {
|
||||
static const uint32 kFrameHeaderSize = 40; // Size from width to data_size.
|
||||
static const uint32 kUnknownDataSize = 0xFFFFFFFF;
|
||||
static const uint32_t kFrameHeaderSize = 40; // Size from width to data_size.
|
||||
static const uint32_t kUnknownDataSize = 0xFFFFFFFF;
|
||||
|
||||
CapturedFrame();
|
||||
|
||||
// Get the number of bytes of the frame data. If data_size is known, return
|
||||
// it directly. Otherwise, calculate the size based on width, height, and
|
||||
// fourcc. Return true if succeeded.
|
||||
bool GetDataSize(uint32* size) const;
|
||||
bool GetDataSize(uint32_t* size) const;
|
||||
|
||||
// TODO(guoweis): Change the type of |rotation| from int to
|
||||
// webrtc::VideoRotation once chromium gets the code.
|
||||
@ -85,16 +85,16 @@ struct CapturedFrame {
|
||||
// The width and height of the captured frame could be different from those
|
||||
// of VideoFormat. Once the first frame is captured, the width, height,
|
||||
// fourcc, pixel_width, and pixel_height should keep the same over frames.
|
||||
int width; // in number of pixels
|
||||
int height; // in number of pixels
|
||||
uint32 fourcc; // compression
|
||||
uint32 pixel_width; // width of a pixel, default is 1
|
||||
uint32 pixel_height; // height of a pixel, default is 1
|
||||
int width; // in number of pixels
|
||||
int height; // in number of pixels
|
||||
uint32_t fourcc; // compression
|
||||
uint32_t pixel_width; // width of a pixel, default is 1
|
||||
uint32_t pixel_height; // height of a pixel, default is 1
|
||||
// TODO(magjed): |elapsed_time| is deprecated - remove once not used anymore.
|
||||
int64 elapsed_time;
|
||||
int64 time_stamp; // timestamp of when the frame was captured, in unix
|
||||
// time with nanosecond units.
|
||||
uint32 data_size; // number of bytes of the frame data
|
||||
int64_t elapsed_time;
|
||||
int64_t time_stamp; // timestamp of when the frame was captured, in unix
|
||||
// time with nanosecond units.
|
||||
uint32_t data_size; // number of bytes of the frame data
|
||||
|
||||
// TODO(guoweis): This can't be converted to VideoRotation yet as it's
|
||||
// used by chrome now.
|
||||
@ -316,7 +316,7 @@ class VideoCapturer
|
||||
|
||||
// subclasses override this virtual method to provide a vector of fourccs, in
|
||||
// order of preference, that are expected by the media engine.
|
||||
virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) = 0;
|
||||
virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) = 0;
|
||||
|
||||
// mutators to set private attributes
|
||||
void SetId(const std::string& id) {
|
||||
@ -341,8 +341,8 @@ class VideoCapturer
|
||||
// Get the distance between the desired format and the supported format.
|
||||
// Return the max distance if they mismatch. See the implementation for
|
||||
// details.
|
||||
int64 GetFormatDistance(const VideoFormat& desired,
|
||||
const VideoFormat& supported);
|
||||
int64_t GetFormatDistance(const VideoFormat& desired,
|
||||
const VideoFormat& supported);
|
||||
|
||||
// Convert captured frame to readable string for LOG messages.
|
||||
std::string ToString(const CapturedFrame* frame) const;
|
||||
|
||||
@ -43,7 +43,7 @@ namespace {
|
||||
const int kMsCallbackWait = 500;
|
||||
// For HD only the height matters.
|
||||
const int kMinHdHeight = 720;
|
||||
const uint32 kTimeout = 5000U;
|
||||
const uint32_t kTimeout = 5000U;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@
|
||||
namespace cricket {
|
||||
|
||||
struct FourCCAliasEntry {
|
||||
uint32 alias;
|
||||
uint32 canonical;
|
||||
uint32_t alias;
|
||||
uint32_t canonical;
|
||||
};
|
||||
|
||||
static const FourCCAliasEntry kFourCCAliases[] = {
|
||||
@ -57,7 +57,7 @@ static const FourCCAliasEntry kFourCCAliases[] = {
|
||||
{FOURCC_CM24, FOURCC_RAW},
|
||||
};
|
||||
|
||||
uint32 CanonicalFourCC(uint32 fourcc) {
|
||||
uint32_t CanonicalFourCC(uint32_t fourcc) {
|
||||
for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) {
|
||||
if (kFourCCAliases[i].alias == fourcc) {
|
||||
return kFourCCAliases[i].canonical;
|
||||
@ -223,7 +223,7 @@ void ComputeScaleToSquarePixels(int in_width, int in_height,
|
||||
// as a multiply defined symbol error. See Also:
|
||||
// http://msdn.microsoft.com/en-us/library/34h23df8.aspx
|
||||
#ifndef _MSC_EXTENSIONS
|
||||
const int64 VideoFormat::kMinimumInterval; // Initialized in header.
|
||||
const int64_t VideoFormat::kMinimumInterval; // Initialized in header.
|
||||
#endif
|
||||
|
||||
std::string VideoFormat::ToString() const {
|
||||
|
||||
@ -42,7 +42,7 @@ namespace cricket {
|
||||
// processing, it doesn't have the correct ssrc. Since currently only Tx
|
||||
// Video processing is supported, this is ok. When we switch over to trigger
|
||||
// from capturer, this should be fixed and this const removed.
|
||||
const uint32 kDummyVideoSsrc = 0xFFFFFFFF;
|
||||
const uint32_t kDummyVideoSsrc = 0xFFFFFFFF;
|
||||
|
||||
// Minimum interval is 10k fps.
|
||||
#define FPS_TO_INTERVAL(fps) \
|
||||
@ -55,9 +55,9 @@ const uint32 kDummyVideoSsrc = 0xFFFFFFFF;
|
||||
// Convert four characters to a FourCC code.
|
||||
// Needs to be a macro otherwise the OS X compiler complains when the kFormat*
|
||||
// constants are used in a switch.
|
||||
#define FOURCC(a, b, c, d) ( \
|
||||
(static_cast<uint32>(a)) | (static_cast<uint32>(b) << 8) | \
|
||||
(static_cast<uint32>(c) << 16) | (static_cast<uint32>(d) << 24))
|
||||
#define FOURCC(a, b, c, d) \
|
||||
((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \
|
||||
(static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24))
|
||||
// Some pages discussing FourCC codes:
|
||||
// http://www.fourcc.org/yuv.php
|
||||
// http://v4l2spec.bytesex.org/spec/book1.htm
|
||||
@ -137,13 +137,13 @@ enum FourCC {
|
||||
// We move this out of the enum because using it in many places caused
|
||||
// the compiler to get grumpy, presumably since the above enum is
|
||||
// backed by an int.
|
||||
static const uint32 FOURCC_ANY = 0xFFFFFFFF;
|
||||
static const uint32_t FOURCC_ANY = 0xFFFFFFFF;
|
||||
|
||||
// Converts fourcc aliases into canonical ones.
|
||||
uint32 CanonicalFourCC(uint32 fourcc);
|
||||
uint32_t CanonicalFourCC(uint32_t fourcc);
|
||||
|
||||
// Get FourCC code as a string.
|
||||
inline std::string GetFourccName(uint32 fourcc) {
|
||||
inline std::string GetFourccName(uint32_t fourcc) {
|
||||
std::string name;
|
||||
name.push_back(static_cast<char>(fourcc & 0xFF));
|
||||
name.push_back(static_cast<char>((fourcc >> 8) & 0xFF));
|
||||
@ -185,19 +185,19 @@ void ComputeScaleToSquarePixels(int in_width, int in_height,
|
||||
struct VideoFormatPod {
|
||||
int width; // Number of pixels.
|
||||
int height; // Number of pixels.
|
||||
int64 interval; // Nanoseconds.
|
||||
uint32 fourcc; // Color space. FOURCC_ANY means that any color space is OK.
|
||||
int64_t interval; // Nanoseconds.
|
||||
uint32_t fourcc; // Color space. FOURCC_ANY means that any color space is OK.
|
||||
};
|
||||
|
||||
struct VideoFormat : VideoFormatPod {
|
||||
static const int64 kMinimumInterval =
|
||||
static const int64_t kMinimumInterval =
|
||||
rtc::kNumNanosecsPerSec / 10000; // 10k fps.
|
||||
|
||||
VideoFormat() {
|
||||
Construct(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
VideoFormat(int w, int h, int64 interval_ns, uint32 cc) {
|
||||
VideoFormat(int w, int h, int64_t interval_ns, uint32_t cc) {
|
||||
Construct(w, h, interval_ns, cc);
|
||||
}
|
||||
|
||||
@ -205,25 +205,25 @@ struct VideoFormat : VideoFormatPod {
|
||||
Construct(format.width, format.height, format.interval, format.fourcc);
|
||||
}
|
||||
|
||||
void Construct(int w, int h, int64 interval_ns, uint32 cc) {
|
||||
void Construct(int w, int h, int64_t interval_ns, uint32_t cc) {
|
||||
width = w;
|
||||
height = h;
|
||||
interval = interval_ns;
|
||||
fourcc = cc;
|
||||
}
|
||||
|
||||
static int64 FpsToInterval(int fps) {
|
||||
static int64_t FpsToInterval(int fps) {
|
||||
return fps ? rtc::kNumNanosecsPerSec / fps : kMinimumInterval;
|
||||
}
|
||||
|
||||
static int IntervalToFps(int64 interval) {
|
||||
static int IntervalToFps(int64_t interval) {
|
||||
if (!interval) {
|
||||
return 0;
|
||||
}
|
||||
return static_cast<int>(rtc::kNumNanosecsPerSec / interval);
|
||||
}
|
||||
|
||||
static float IntervalToFpsFloat(int64 interval) {
|
||||
static float IntervalToFpsFloat(int64_t interval) {
|
||||
if (!interval) {
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
@ -58,13 +58,13 @@
|
||||
EXPECT_TRUE_WAIT((r).num_rendered_frames() >= (c) && \
|
||||
(w) == (r).width() && \
|
||||
(h) == (r).height(), (t)); \
|
||||
EXPECT_EQ(0, (r).errors()); \
|
||||
EXPECT_EQ(0, (r).errors());
|
||||
|
||||
static const uint32 kTimeout = 5000U;
|
||||
static const uint32 kDefaultReceiveSsrc = 0;
|
||||
static const uint32 kSsrc = 1234u;
|
||||
static const uint32 kRtxSsrc = 4321u;
|
||||
static const uint32 kSsrcs4[] = {1, 2, 3, 4};
|
||||
static const uint32_t kTimeout = 5000U;
|
||||
static const uint32_t kDefaultReceiveSsrc = 0;
|
||||
static const uint32_t kSsrc = 1234u;
|
||||
static const uint32_t kRtxSsrc = 4321u;
|
||||
static const uint32_t kSsrcs4[] = {1, 2, 3, 4};
|
||||
|
||||
inline bool IsEqualRes(const cricket::VideoCodec& a, int w, int h, int fps) {
|
||||
return a.width == w && a.height == h && a.framerate == fps;
|
||||
@ -119,8 +119,9 @@ class VideoEngineOverride : public T {
|
||||
const cricket::VideoFormat*) {
|
||||
}
|
||||
|
||||
void TriggerMediaFrame(
|
||||
uint32 ssrc, cricket::VideoFrame* frame, bool* drop_frame) {
|
||||
void TriggerMediaFrame(uint32_t ssrc,
|
||||
cricket::VideoFrame* frame,
|
||||
bool* drop_frame) {
|
||||
T::SignalMediaFrame(ssrc, frame, drop_frame);
|
||||
}
|
||||
};
|
||||
@ -553,7 +554,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
bool SetSend(bool send) {
|
||||
return channel_->SetSend(send);
|
||||
}
|
||||
bool SetSendStreamFormat(uint32 ssrc, const cricket::VideoCodec& codec) {
|
||||
bool SetSendStreamFormat(uint32_t ssrc, const cricket::VideoCodec& codec) {
|
||||
return channel_->SetSendStreamFormat(ssrc, cricket::VideoFormat(
|
||||
codec.width, codec.height,
|
||||
cricket::VideoFormat::FpsToInterval(codec.framerate),
|
||||
@ -604,13 +605,13 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
int NumRtpBytes() {
|
||||
return network_interface_.NumRtpBytes();
|
||||
}
|
||||
int NumRtpBytes(uint32 ssrc) {
|
||||
int NumRtpBytes(uint32_t ssrc) {
|
||||
return network_interface_.NumRtpBytes(ssrc);
|
||||
}
|
||||
int NumRtpPackets() {
|
||||
return network_interface_.NumRtpPackets();
|
||||
}
|
||||
int NumRtpPackets(uint32 ssrc) {
|
||||
int NumRtpPackets(uint32_t ssrc) {
|
||||
return network_interface_.NumRtpPackets(ssrc);
|
||||
}
|
||||
int NumSentSsrcs() {
|
||||
@ -630,18 +631,22 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
ParseRtpPacket(p, NULL, &pt, NULL, NULL, NULL, NULL);
|
||||
return pt;
|
||||
}
|
||||
static bool ParseRtpPacket(const rtc::Buffer* p, bool* x, int* pt,
|
||||
int* seqnum, uint32* tstamp, uint32* ssrc,
|
||||
static bool ParseRtpPacket(const rtc::Buffer* p,
|
||||
bool* x,
|
||||
int* pt,
|
||||
int* seqnum,
|
||||
uint32_t* tstamp,
|
||||
uint32_t* ssrc,
|
||||
std::string* payload) {
|
||||
rtc::ByteBuffer buf(*p);
|
||||
uint8 u08 = 0;
|
||||
uint16 u16 = 0;
|
||||
uint32 u32 = 0;
|
||||
uint8_t u08 = 0;
|
||||
uint16_t u16 = 0;
|
||||
uint32_t u32 = 0;
|
||||
|
||||
// Read X and CC fields.
|
||||
if (!buf.ReadUInt8(&u08)) return false;
|
||||
bool extension = ((u08 & 0x10) != 0);
|
||||
uint8 cc = (u08 & 0x0F);
|
||||
uint8_t cc = (u08 & 0x0F);
|
||||
if (x) *x = extension;
|
||||
|
||||
// Read PT field.
|
||||
@ -661,7 +666,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
if (ssrc) *ssrc = u32;
|
||||
|
||||
// Skip CSRCs.
|
||||
for (uint8 i = 0; i < cc; ++i) {
|
||||
for (uint8_t i = 0; i < cc; ++i) {
|
||||
if (!buf.ReadUInt32(&u32)) return false;
|
||||
}
|
||||
|
||||
@ -672,10 +677,10 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
|
||||
// Read Extension header length
|
||||
if (!buf.ReadUInt16(&u16)) return false;
|
||||
uint16 ext_header_len = u16;
|
||||
uint16_t ext_header_len = u16;
|
||||
|
||||
// Read Extension header
|
||||
for (uint16 i = 0; i < ext_header_len; ++i) {
|
||||
for (uint16_t i = 0; i < ext_header_len; ++i) {
|
||||
if (!buf.ReadUInt32(&u32)) return false;
|
||||
}
|
||||
}
|
||||
@ -698,9 +703,9 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
// The packet may be a compound RTCP packet.
|
||||
while (total_len < p->size()) {
|
||||
// Read FMT, type and length.
|
||||
uint8 fmt = 0;
|
||||
uint8 type = 0;
|
||||
uint16 length = 0;
|
||||
uint8_t fmt = 0;
|
||||
uint8_t type = 0;
|
||||
uint16_t length = 0;
|
||||
if (!buf.ReadUInt8(&fmt)) return false;
|
||||
fmt &= 0x1F;
|
||||
if (!buf.ReadUInt8(&type)) return false;
|
||||
@ -719,7 +724,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnVideoChannelError(uint32 ssrc,
|
||||
void OnVideoChannelError(uint32_t ssrc,
|
||||
cricket::VideoMediaChannel::Error error) {
|
||||
media_error_ = error;
|
||||
}
|
||||
@ -881,7 +886,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(channel_->SetRenderer(2, &renderer2));
|
||||
EXPECT_EQ(0, renderer1.num_rendered_frames());
|
||||
EXPECT_EQ(0, renderer2.num_rendered_frames());
|
||||
std::vector<uint32> ssrcs;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
ssrcs.push_back(1);
|
||||
ssrcs.push_back(2);
|
||||
network_interface_.SetConferenceMode(true, ssrcs);
|
||||
@ -958,7 +963,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
// the number of expected packets have been sent to avoid races where we
|
||||
// check stats before it has been updated.
|
||||
cricket::VideoMediaInfo info;
|
||||
for (uint32 i = 0; i < kTimeout; ++i) {
|
||||
for (uint32_t i = 0; i < kTimeout; ++i) {
|
||||
rtc::Thread::Current()->ProcessMessages(1);
|
||||
EXPECT_TRUE(channel_->GetStats(&info));
|
||||
ASSERT_EQ(2U, info.senders.size());
|
||||
@ -1000,7 +1005,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(SetSend(true));
|
||||
EXPECT_TRUE(SendFrame());
|
||||
EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
|
||||
uint32 ssrc = 0;
|
||||
uint32_t ssrc = 0;
|
||||
rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
|
||||
ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
|
||||
EXPECT_EQ(kSsrc, ssrc);
|
||||
@ -1022,7 +1027,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(SetSend(true));
|
||||
EXPECT_TRUE(WaitAndSendFrame(0));
|
||||
EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
|
||||
uint32 ssrc = 0;
|
||||
uint32_t ssrc = 0;
|
||||
rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
|
||||
ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
|
||||
EXPECT_EQ(999u, ssrc);
|
||||
@ -1035,9 +1040,8 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
// Test that we can set the default video renderer before and after
|
||||
// media is received.
|
||||
void SetRenderer() {
|
||||
uint8 data1[] = {
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
uint8_t data1[] = {
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
rtc::Buffer packet1(data1, sizeof(data1));
|
||||
rtc::SetBE32(packet1.data() + 8, kSsrc);
|
||||
@ -1070,7 +1074,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(SendFrame());
|
||||
EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
|
||||
EXPECT_GT(NumRtpPackets(), 0);
|
||||
uint32 ssrc = 0;
|
||||
uint32_t ssrc = 0;
|
||||
size_t last_packet = NumRtpPackets() - 1;
|
||||
rtc::scoped_ptr<const rtc::Buffer>
|
||||
p(GetRtpPacket(static_cast<int>(last_packet)));
|
||||
@ -1243,7 +1247,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(channel_->SetRenderer(2, &renderer2));
|
||||
EXPECT_EQ(0, renderer1.num_rendered_frames());
|
||||
EXPECT_EQ(0, renderer2.num_rendered_frames());
|
||||
std::vector<uint32> ssrcs;
|
||||
std::vector<uint32_t> ssrcs;
|
||||
ssrcs.push_back(1);
|
||||
ssrcs.push_back(2);
|
||||
network_interface_.SetConferenceMode(true, ssrcs);
|
||||
@ -1608,8 +1612,8 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
// This frame should be received.
|
||||
EXPECT_TRUE(SendFrame());
|
||||
EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
|
||||
const int64 interval = cricket::VideoFormat::FpsToInterval(
|
||||
DefaultCodec().framerate);
|
||||
const int64_t interval =
|
||||
cricket::VideoFormat::FpsToInterval(DefaultCodec().framerate);
|
||||
cricket::VideoFormat format(
|
||||
0,
|
||||
0,
|
||||
@ -1719,7 +1723,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_FALSE(channel_->RemoveSendStream(kSsrc));
|
||||
// Default channel is no longer used by a stream.
|
||||
EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc());
|
||||
uint32 new_ssrc = kSsrc + 100;
|
||||
uint32_t new_ssrc = kSsrc + 100;
|
||||
EXPECT_TRUE(channel_->AddSendStream(
|
||||
cricket::StreamParams::CreateLegacy(new_ssrc)));
|
||||
// Re-use default channel.
|
||||
|
||||
@ -44,15 +44,15 @@ namespace cricket {
|
||||
rtc::StreamResult VideoFrame::Write(rtc::StreamInterface* stream,
|
||||
int* error) const {
|
||||
rtc::StreamResult result = rtc::SR_SUCCESS;
|
||||
const uint8* src_y = GetYPlane();
|
||||
const uint8* src_u = GetUPlane();
|
||||
const uint8* src_v = GetVPlane();
|
||||
const uint8_t* src_y = GetYPlane();
|
||||
const uint8_t* src_u = GetUPlane();
|
||||
const uint8_t* src_v = GetVPlane();
|
||||
if (!src_y || !src_u || !src_v) {
|
||||
return result; // Nothing to write.
|
||||
}
|
||||
const int32 y_pitch = GetYPitch();
|
||||
const int32 u_pitch = GetUPitch();
|
||||
const int32 v_pitch = GetVPitch();
|
||||
const int32_t y_pitch = GetYPitch();
|
||||
const int32_t u_pitch = GetUPitch();
|
||||
const int32_t v_pitch = GetVPitch();
|
||||
const size_t width = GetWidth();
|
||||
const size_t height = GetHeight();
|
||||
const size_t half_width = (width + 1) >> 1;
|
||||
@ -81,7 +81,7 @@ rtc::StreamResult VideoFrame::Write(rtc::StreamInterface* stream,
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t VideoFrame::CopyToBuffer(uint8* buffer, size_t size) const {
|
||||
size_t VideoFrame::CopyToBuffer(uint8_t* buffer, size_t size) const {
|
||||
const size_t y_size = GetHeight() * GetYPitch();
|
||||
const size_t u_size = GetUPitch() * GetChromaHeight();
|
||||
const size_t v_size = GetVPitch() * GetChromaHeight();
|
||||
@ -93,15 +93,18 @@ size_t VideoFrame::CopyToBuffer(uint8* buffer, size_t size) const {
|
||||
return needed;
|
||||
}
|
||||
|
||||
bool VideoFrame::CopyToPlanes(
|
||||
uint8* dst_y, uint8* dst_u, uint8* dst_v,
|
||||
int32 dst_pitch_y, int32 dst_pitch_u, int32 dst_pitch_v) const {
|
||||
bool VideoFrame::CopyToPlanes(uint8_t* dst_y,
|
||||
uint8_t* dst_u,
|
||||
uint8_t* dst_v,
|
||||
int32_t dst_pitch_y,
|
||||
int32_t dst_pitch_u,
|
||||
int32_t dst_pitch_v) const {
|
||||
if (!GetYPlane() || !GetUPlane() || !GetVPlane()) {
|
||||
LOG(LS_ERROR) << "NULL plane pointer.";
|
||||
return false;
|
||||
}
|
||||
int32 src_width = static_cast<int>(GetWidth());
|
||||
int32 src_height = static_cast<int>(GetHeight());
|
||||
int32_t src_width = static_cast<int>(GetWidth());
|
||||
int32_t src_height = static_cast<int>(GetHeight());
|
||||
return libyuv::I420Copy(GetYPlane(), GetYPitch(),
|
||||
GetUPlane(), GetUPitch(),
|
||||
GetVPlane(), GetVPitch(),
|
||||
@ -121,8 +124,8 @@ void VideoFrame::CopyToFrame(VideoFrame* dst) const {
|
||||
dst->GetYPitch(), dst->GetUPitch(), dst->GetVPitch());
|
||||
}
|
||||
|
||||
size_t VideoFrame::ConvertToRgbBuffer(uint32 to_fourcc,
|
||||
uint8* buffer,
|
||||
size_t VideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc,
|
||||
uint8_t* buffer,
|
||||
size_t size,
|
||||
int stride_rgb) const {
|
||||
const size_t needed = std::abs(stride_rgb) * GetHeight();
|
||||
@ -142,10 +145,16 @@ size_t VideoFrame::ConvertToRgbBuffer(uint32 to_fourcc,
|
||||
}
|
||||
|
||||
// TODO(fbarchard): Handle odd width/height with rounding.
|
||||
void VideoFrame::StretchToPlanes(
|
||||
uint8* dst_y, uint8* dst_u, uint8* dst_v,
|
||||
int32 dst_pitch_y, int32 dst_pitch_u, int32 dst_pitch_v,
|
||||
size_t width, size_t height, bool interpolate, bool vert_crop) const {
|
||||
void VideoFrame::StretchToPlanes(uint8_t* dst_y,
|
||||
uint8_t* dst_u,
|
||||
uint8_t* dst_v,
|
||||
int32_t dst_pitch_y,
|
||||
int32_t dst_pitch_u,
|
||||
int32_t dst_pitch_v,
|
||||
size_t width,
|
||||
size_t height,
|
||||
bool interpolate,
|
||||
bool vert_crop) const {
|
||||
if (!GetYPlane() || !GetUPlane() || !GetVPlane()) {
|
||||
LOG(LS_ERROR) << "NULL plane pointer.";
|
||||
return;
|
||||
@ -157,24 +166,24 @@ void VideoFrame::StretchToPlanes(
|
||||
CopyToPlanes(dst_y, dst_u, dst_v, dst_pitch_y, dst_pitch_u, dst_pitch_v);
|
||||
return;
|
||||
}
|
||||
const uint8* src_y = GetYPlane();
|
||||
const uint8* src_u = GetUPlane();
|
||||
const uint8* src_v = GetVPlane();
|
||||
const uint8_t* src_y = GetYPlane();
|
||||
const uint8_t* src_u = GetUPlane();
|
||||
const uint8_t* src_v = GetVPlane();
|
||||
|
||||
if (vert_crop) {
|
||||
// Adjust the input width:height ratio to be the same as the output ratio.
|
||||
if (src_width * height > src_height * width) {
|
||||
// Reduce the input width, but keep size/position aligned for YuvScaler
|
||||
src_width = ROUNDTO2(src_height * width / height);
|
||||
int32 iwidth_offset = ROUNDTO2((GetWidth() - src_width) / 2);
|
||||
int32_t iwidth_offset = ROUNDTO2((GetWidth() - src_width) / 2);
|
||||
src_y += iwidth_offset;
|
||||
src_u += iwidth_offset / 2;
|
||||
src_v += iwidth_offset / 2;
|
||||
} else if (src_width * height < src_height * width) {
|
||||
// Reduce the input height.
|
||||
src_height = src_width * height / width;
|
||||
int32 iheight_offset = static_cast<int32>(
|
||||
(GetHeight() - src_height) >> 2);
|
||||
int32_t iheight_offset =
|
||||
static_cast<int32_t>((GetHeight() - src_height) >> 2);
|
||||
iheight_offset <<= 1; // Ensure that iheight_offset is even.
|
||||
src_y += iheight_offset * GetYPitch();
|
||||
src_u += iheight_offset / 2 * GetUPitch();
|
||||
@ -230,8 +239,11 @@ bool VideoFrame::SetToBlack() {
|
||||
|
||||
static const size_t kMaxSampleSize = 1000000000u;
|
||||
// Returns whether a sample is valid.
|
||||
bool VideoFrame::Validate(uint32 fourcc, int w, int h,
|
||||
const uint8 *sample, size_t sample_size) {
|
||||
bool VideoFrame::Validate(uint32_t fourcc,
|
||||
int w,
|
||||
int h,
|
||||
const uint8_t* sample,
|
||||
size_t sample_size) {
|
||||
if (h < 0) {
|
||||
h = -h;
|
||||
}
|
||||
@ -240,7 +252,7 @@ bool VideoFrame::Validate(uint32 fourcc, int w, int h,
|
||||
LOG(LS_ERROR) << "Invalid dimensions: " << w << "x" << h;
|
||||
return false;
|
||||
}
|
||||
uint32 format = CanonicalFourCC(fourcc);
|
||||
uint32_t format = CanonicalFourCC(fourcc);
|
||||
int expected_bpp = 8;
|
||||
switch (format) {
|
||||
case FOURCC_I400:
|
||||
@ -305,7 +317,7 @@ bool VideoFrame::Validate(uint32 fourcc, int w, int h,
|
||||
return false;
|
||||
}
|
||||
// TODO(fbarchard): Make function to dump information about frames.
|
||||
uint8 four_samples[4] = { 0, 0, 0, 0 };
|
||||
uint8_t four_samples[4] = {0, 0, 0, 0};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(four_samples) && i < sample_size; ++i) {
|
||||
four_samples[i] = sample[i];
|
||||
}
|
||||
|
||||
@ -49,12 +49,12 @@ class VideoFrame {
|
||||
// |dh| is destination height, like |dw|, but must be a positive number.
|
||||
// Returns whether the function succeeded or failed.
|
||||
|
||||
virtual bool Reset(uint32 fourcc,
|
||||
virtual bool Reset(uint32_t fourcc,
|
||||
int w,
|
||||
int h,
|
||||
int dw,
|
||||
int dh,
|
||||
uint8* sample,
|
||||
uint8_t* sample,
|
||||
size_t sample_size,
|
||||
size_t pixel_width,
|
||||
size_t pixel_height,
|
||||
@ -63,12 +63,12 @@ class VideoFrame {
|
||||
bool apply_rotation) = 0;
|
||||
|
||||
// TODO(guoweis): Remove this once all external implementations are updated.
|
||||
virtual bool Reset(uint32 fourcc,
|
||||
virtual bool Reset(uint32_t fourcc,
|
||||
int w,
|
||||
int h,
|
||||
int dw,
|
||||
int dh,
|
||||
uint8* sample,
|
||||
uint8_t* sample,
|
||||
size_t sample_size,
|
||||
size_t pixel_width,
|
||||
size_t pixel_height,
|
||||
@ -88,16 +88,16 @@ class VideoFrame {
|
||||
size_t GetChromaHeight() const { return (GetHeight() + 1) / 2; }
|
||||
size_t GetChromaSize() const { return GetUPitch() * GetChromaHeight(); }
|
||||
// These can return NULL if the object is not backed by a buffer.
|
||||
virtual const uint8 *GetYPlane() const = 0;
|
||||
virtual const uint8 *GetUPlane() const = 0;
|
||||
virtual const uint8 *GetVPlane() const = 0;
|
||||
virtual uint8 *GetYPlane() = 0;
|
||||
virtual uint8 *GetUPlane() = 0;
|
||||
virtual uint8 *GetVPlane() = 0;
|
||||
virtual const uint8_t* GetYPlane() const = 0;
|
||||
virtual const uint8_t* GetUPlane() const = 0;
|
||||
virtual const uint8_t* GetVPlane() const = 0;
|
||||
virtual uint8_t* GetYPlane() = 0;
|
||||
virtual uint8_t* GetUPlane() = 0;
|
||||
virtual uint8_t* GetVPlane() = 0;
|
||||
|
||||
virtual int32 GetYPitch() const = 0;
|
||||
virtual int32 GetUPitch() const = 0;
|
||||
virtual int32 GetVPitch() const = 0;
|
||||
virtual int32_t GetYPitch() const = 0;
|
||||
virtual int32_t GetUPitch() const = 0;
|
||||
virtual int32_t GetVPitch() const = 0;
|
||||
|
||||
// Returns the handle of the underlying video frame. This is used when the
|
||||
// frame is backed by a texture. The object should be destroyed when it is no
|
||||
@ -144,15 +144,18 @@ class VideoFrame {
|
||||
// sufficient size. Returns the frame's actual size, regardless of whether
|
||||
// it was written or not (like snprintf). If there is insufficient space,
|
||||
// nothing is written.
|
||||
virtual size_t CopyToBuffer(uint8 *buffer, size_t size) const;
|
||||
virtual size_t CopyToBuffer(uint8_t* buffer, size_t size) const;
|
||||
|
||||
// Writes the frame into the given planes, stretched to the given width and
|
||||
// height. The parameter "interpolate" controls whether to interpolate or just
|
||||
// take the nearest-point. The parameter "crop" controls whether to crop this
|
||||
// frame to the aspect ratio of the given dimensions before stretching.
|
||||
virtual bool CopyToPlanes(
|
||||
uint8* dst_y, uint8* dst_u, uint8* dst_v,
|
||||
int32 dst_pitch_y, int32 dst_pitch_u, int32 dst_pitch_v) const;
|
||||
virtual bool CopyToPlanes(uint8_t* dst_y,
|
||||
uint8_t* dst_u,
|
||||
uint8_t* dst_v,
|
||||
int32_t dst_pitch_y,
|
||||
int32_t dst_pitch_u,
|
||||
int32_t dst_pitch_v) const;
|
||||
|
||||
// Writes the frame into the target VideoFrame.
|
||||
virtual void CopyToFrame(VideoFrame* target) const;
|
||||
@ -172,16 +175,25 @@ class VideoFrame {
|
||||
// Returns the frame's actual size, regardless of whether it was written or
|
||||
// not (like snprintf). Parameters size and stride_rgb are in units of bytes.
|
||||
// If there is insufficient space, nothing is written.
|
||||
virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8 *buffer,
|
||||
size_t size, int stride_rgb) const;
|
||||
virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc,
|
||||
uint8_t* buffer,
|
||||
size_t size,
|
||||
int stride_rgb) const;
|
||||
|
||||
// Writes the frame into the given planes, stretched to the given width and
|
||||
// height. The parameter "interpolate" controls whether to interpolate or just
|
||||
// take the nearest-point. The parameter "crop" controls whether to crop this
|
||||
// frame to the aspect ratio of the given dimensions before stretching.
|
||||
virtual void StretchToPlanes(
|
||||
uint8 *y, uint8 *u, uint8 *v, int32 pitchY, int32 pitchU, int32 pitchV,
|
||||
size_t width, size_t height, bool interpolate, bool crop) const;
|
||||
virtual void StretchToPlanes(uint8_t* y,
|
||||
uint8_t* u,
|
||||
uint8_t* v,
|
||||
int32_t pitchY,
|
||||
int32_t pitchU,
|
||||
int32_t pitchV,
|
||||
size_t width,
|
||||
size_t height,
|
||||
bool interpolate,
|
||||
bool crop) const;
|
||||
|
||||
// Writes the frame into the target VideoFrame, stretched to the size of that
|
||||
// frame. The parameter "interpolate" controls whether to interpolate or just
|
||||
@ -201,7 +213,10 @@ class VideoFrame {
|
||||
virtual bool SetToBlack();
|
||||
|
||||
// Tests if sample is valid. Returns true if valid.
|
||||
static bool Validate(uint32 fourcc, int w, int h, const uint8 *sample,
|
||||
static bool Validate(uint32_t fourcc,
|
||||
int w,
|
||||
int h,
|
||||
const uint8_t* sample,
|
||||
size_t sample_size);
|
||||
|
||||
// Size of an I420 image of given dimensions when stored as a frame buffer.
|
||||
|
||||
@ -82,15 +82,18 @@ class VideoFrameTest : public testing::Test {
|
||||
return success;
|
||||
}
|
||||
|
||||
bool LoadFrame(const std::string& filename, uint32 format,
|
||||
int32 width, int32 height, T* frame) {
|
||||
bool LoadFrame(const std::string& filename,
|
||||
uint32_t format,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
T* frame) {
|
||||
return LoadFrame(filename, format, width, height, width, abs(height),
|
||||
webrtc::kVideoRotation_0, frame);
|
||||
}
|
||||
bool LoadFrame(const std::string& filename,
|
||||
uint32 format,
|
||||
int32 width,
|
||||
int32 height,
|
||||
uint32_t format,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int dw,
|
||||
int dh,
|
||||
webrtc::VideoRotation rotation,
|
||||
@ -99,15 +102,18 @@ class VideoFrameTest : public testing::Test {
|
||||
return LoadFrame(ms.get(), format, width, height, dw, dh, rotation, frame);
|
||||
}
|
||||
// Load a video frame from a memory stream.
|
||||
bool LoadFrame(rtc::MemoryStream* ms, uint32 format,
|
||||
int32 width, int32 height, T* frame) {
|
||||
bool LoadFrame(rtc::MemoryStream* ms,
|
||||
uint32_t format,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
T* frame) {
|
||||
return LoadFrame(ms, format, width, height, width, abs(height),
|
||||
webrtc::kVideoRotation_0, frame);
|
||||
}
|
||||
bool LoadFrame(rtc::MemoryStream* ms,
|
||||
uint32 format,
|
||||
int32 width,
|
||||
int32 height,
|
||||
uint32_t format,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int dw,
|
||||
int dh,
|
||||
webrtc::VideoRotation rotation,
|
||||
@ -119,22 +125,26 @@ class VideoFrameTest : public testing::Test {
|
||||
bool ret = ms->GetSize(&data_size);
|
||||
EXPECT_TRUE(ret);
|
||||
if (ret) {
|
||||
ret = LoadFrame(reinterpret_cast<uint8*>(ms->GetBuffer()), data_size,
|
||||
ret = LoadFrame(reinterpret_cast<uint8_t*>(ms->GetBuffer()), data_size,
|
||||
format, width, height, dw, dh, rotation, frame);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// Load a frame from a raw buffer.
|
||||
bool LoadFrame(uint8* sample, size_t sample_size, uint32 format,
|
||||
int32 width, int32 height, T* frame) {
|
||||
bool LoadFrame(uint8_t* sample,
|
||||
size_t sample_size,
|
||||
uint32_t format,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
T* frame) {
|
||||
return LoadFrame(sample, sample_size, format, width, height, width,
|
||||
abs(height), webrtc::kVideoRotation_0, frame);
|
||||
}
|
||||
bool LoadFrame(uint8* sample,
|
||||
bool LoadFrame(uint8_t* sample,
|
||||
size_t sample_size,
|
||||
uint32 format,
|
||||
int32 width,
|
||||
int32 height,
|
||||
uint32_t format,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int dw,
|
||||
int dh,
|
||||
webrtc::VideoRotation rotation,
|
||||
@ -178,7 +188,7 @@ class VideoFrameTest : public testing::Test {
|
||||
prefix.c_str(), frame.GetWidth(), frame.GetHeight());
|
||||
size_t out_size = cricket::VideoFrame::SizeOf(frame.GetWidth(),
|
||||
frame.GetHeight());
|
||||
rtc::scoped_ptr<uint8[]> out(new uint8[out_size]);
|
||||
rtc::scoped_ptr<uint8_t[]> out(new uint8_t[out_size]);
|
||||
frame.CopyToBuffer(out.get(), out_size);
|
||||
return DumpSample(filename, out.get(), out_size);
|
||||
}
|
||||
@ -200,8 +210,9 @@ class VideoFrameTest : public testing::Test {
|
||||
// The pattern is { { green, orange }, { blue, purple } }
|
||||
// There is also a gradient within each square to ensure that the luma
|
||||
// values are handled properly.
|
||||
rtc::MemoryStream* CreateYuv422Sample(uint32 fourcc,
|
||||
uint32 width, uint32 height) {
|
||||
rtc::MemoryStream* CreateYuv422Sample(uint32_t fourcc,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
int y1_pos, y2_pos, u_pos, v_pos;
|
||||
if (!GetYuv422Packing(fourcc, &y1_pos, &y2_pos, &u_pos, &v_pos)) {
|
||||
return NULL;
|
||||
@ -214,9 +225,9 @@ class VideoFrameTest : public testing::Test {
|
||||
if (!ms->ReserveSize(size)) {
|
||||
return NULL;
|
||||
}
|
||||
for (uint32 y = 0; y < height; ++y) {
|
||||
for (uint32_t y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < awidth; x += 2) {
|
||||
uint8 quad[4];
|
||||
uint8_t quad[4];
|
||||
quad[y1_pos] = (x % 63 + y % 63) + 64;
|
||||
quad[y2_pos] = ((x + 1) % 63 + y % 63) + 64;
|
||||
quad[u_pos] = ((x / 63) & 1) ? 192 : 64;
|
||||
@ -228,23 +239,25 @@ class VideoFrameTest : public testing::Test {
|
||||
}
|
||||
|
||||
// Create a test image for YUV 420 formats with 12 bits per pixel.
|
||||
rtc::MemoryStream* CreateYuvSample(uint32 width, uint32 height,
|
||||
uint32 bpp) {
|
||||
rtc::MemoryStream* CreateYuvSample(uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t bpp) {
|
||||
rtc::scoped_ptr<rtc::MemoryStream> ms(
|
||||
new rtc::MemoryStream);
|
||||
if (!ms->ReserveSize(width * height * bpp / 8)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < width * height * bpp / 8; ++i) {
|
||||
for (uint32_t i = 0; i < width * height * bpp / 8; ++i) {
|
||||
char value = ((i / 63) & 1) ? 192 : 64;
|
||||
ms->Write(&value, sizeof(value), NULL, NULL);
|
||||
}
|
||||
return ms.release();
|
||||
}
|
||||
|
||||
rtc::MemoryStream* CreateRgbSample(uint32 fourcc,
|
||||
uint32 width, uint32 height) {
|
||||
rtc::MemoryStream* CreateRgbSample(uint32_t fourcc,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
int r_pos, g_pos, b_pos, bytes;
|
||||
if (!GetRgbPacking(fourcc, &r_pos, &g_pos, &b_pos, &bytes)) {
|
||||
return NULL;
|
||||
@ -256,9 +269,9 @@ class VideoFrameTest : public testing::Test {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (uint32 y = 0; y < height; ++y) {
|
||||
for (uint32 x = 0; x < width; ++x) {
|
||||
uint8 rgb[4] = { 255, 255, 255, 255 };
|
||||
for (uint32_t y = 0; y < height; ++y) {
|
||||
for (uint32_t x = 0; x < width; ++x) {
|
||||
uint8_t rgb[4] = {255, 255, 255, 255};
|
||||
rgb[r_pos] = ((x / 63) & 1) ? 224 : 32;
|
||||
rgb[g_pos] = (x % 63 + y % 63) + 96;
|
||||
rgb[b_pos] = ((y / 63) & 1) ? 224 : 32;
|
||||
@ -271,28 +284,30 @@ class VideoFrameTest : public testing::Test {
|
||||
// Simple conversion routines to verify the optimized VideoFrame routines.
|
||||
// Converts from the specified colorspace to I420.
|
||||
bool ConvertYuv422(const rtc::MemoryStream* ms,
|
||||
uint32 fourcc, uint32 width, uint32 height,
|
||||
uint32_t fourcc,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
T* frame) {
|
||||
int y1_pos, y2_pos, u_pos, v_pos;
|
||||
if (!GetYuv422Packing(fourcc, &y1_pos, &y2_pos, &u_pos, &v_pos)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8* start = reinterpret_cast<const uint8*>(ms->GetBuffer());
|
||||
const uint8_t* start = reinterpret_cast<const uint8_t*>(ms->GetBuffer());
|
||||
int awidth = (width + 1) & ~1;
|
||||
frame->InitToBlack(width, height, 1, 1, 0);
|
||||
int stride_y = frame->GetYPitch();
|
||||
int stride_u = frame->GetUPitch();
|
||||
int stride_v = frame->GetVPitch();
|
||||
for (uint32 y = 0; y < height; ++y) {
|
||||
for (uint32 x = 0; x < width; x += 2) {
|
||||
const uint8* quad1 = start + (y * awidth + x) * 2;
|
||||
for (uint32_t y = 0; y < height; ++y) {
|
||||
for (uint32_t x = 0; x < width; x += 2) {
|
||||
const uint8_t* quad1 = start + (y * awidth + x) * 2;
|
||||
frame->GetYPlane()[stride_y * y + x] = quad1[y1_pos];
|
||||
if ((x + 1) < width) {
|
||||
frame->GetYPlane()[stride_y * y + x + 1] = quad1[y2_pos];
|
||||
}
|
||||
if ((y & 1) == 0) {
|
||||
const uint8* quad2 = quad1 + awidth * 2;
|
||||
const uint8_t* quad2 = quad1 + awidth * 2;
|
||||
if ((y + 1) >= height) {
|
||||
quad2 = quad1;
|
||||
}
|
||||
@ -309,14 +324,16 @@ class VideoFrameTest : public testing::Test {
|
||||
// Convert RGB to 420.
|
||||
// A negative height inverts the image.
|
||||
bool ConvertRgb(const rtc::MemoryStream* ms,
|
||||
uint32 fourcc, int32 width, int32 height,
|
||||
uint32_t fourcc,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
T* frame) {
|
||||
int r_pos, g_pos, b_pos, bytes;
|
||||
if (!GetRgbPacking(fourcc, &r_pos, &g_pos, &b_pos, &bytes)) {
|
||||
return false;
|
||||
}
|
||||
int pitch = width * bytes;
|
||||
const uint8* start = reinterpret_cast<const uint8*>(ms->GetBuffer());
|
||||
const uint8_t* start = reinterpret_cast<const uint8_t*>(ms->GetBuffer());
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
start = start + pitch * (height - 1);
|
||||
@ -326,10 +343,10 @@ class VideoFrameTest : public testing::Test {
|
||||
int stride_y = frame->GetYPitch();
|
||||
int stride_u = frame->GetUPitch();
|
||||
int stride_v = frame->GetVPitch();
|
||||
for (int32 y = 0; y < height; y += 2) {
|
||||
for (int32 x = 0; x < width; x += 2) {
|
||||
const uint8* rgb[4];
|
||||
uint8 yuv[4][3];
|
||||
for (int32_t y = 0; y < height; y += 2) {
|
||||
for (int32_t x = 0; x < width; x += 2) {
|
||||
const uint8_t* rgb[4];
|
||||
uint8_t yuv[4][3];
|
||||
rgb[0] = start + y * pitch + x * bytes;
|
||||
rgb[1] = rgb[0] + ((x + 1) < width ? bytes : 0);
|
||||
rgb[2] = rgb[0] + ((y + 1) < height ? pitch : 0);
|
||||
@ -358,15 +375,22 @@ class VideoFrameTest : public testing::Test {
|
||||
}
|
||||
|
||||
// Simple and slow RGB->YUV conversion. From NTSC standard, c/o Wikipedia.
|
||||
void ConvertRgbPixel(uint8 r, uint8 g, uint8 b,
|
||||
uint8* y, uint8* u, uint8* v) {
|
||||
void ConvertRgbPixel(uint8_t r,
|
||||
uint8_t g,
|
||||
uint8_t b,
|
||||
uint8_t* y,
|
||||
uint8_t* u,
|
||||
uint8_t* v) {
|
||||
*y = static_cast<int>(.257 * r + .504 * g + .098 * b) + 16;
|
||||
*u = static_cast<int>(-.148 * r - .291 * g + .439 * b) + 128;
|
||||
*v = static_cast<int>(.439 * r - .368 * g - .071 * b) + 128;
|
||||
}
|
||||
|
||||
bool GetYuv422Packing(uint32 fourcc,
|
||||
int* y1_pos, int* y2_pos, int* u_pos, int* v_pos) {
|
||||
bool GetYuv422Packing(uint32_t fourcc,
|
||||
int* y1_pos,
|
||||
int* y2_pos,
|
||||
int* u_pos,
|
||||
int* v_pos) {
|
||||
if (fourcc == cricket::FOURCC_YUY2) {
|
||||
*y1_pos = 0; *u_pos = 1; *y2_pos = 2; *v_pos = 3;
|
||||
} else if (fourcc == cricket::FOURCC_UYVY) {
|
||||
@ -377,8 +401,11 @@ class VideoFrameTest : public testing::Test {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetRgbPacking(uint32 fourcc,
|
||||
int* r_pos, int* g_pos, int* b_pos, int* bytes) {
|
||||
bool GetRgbPacking(uint32_t fourcc,
|
||||
int* r_pos,
|
||||
int* g_pos,
|
||||
int* b_pos,
|
||||
int* bytes) {
|
||||
if (fourcc == cricket::FOURCC_RAW) {
|
||||
*r_pos = 0; *g_pos = 1; *b_pos = 2; *bytes = 3; // RGB in memory.
|
||||
} else if (fourcc == cricket::FOURCC_24BG) {
|
||||
@ -401,23 +428,26 @@ class VideoFrameTest : public testing::Test {
|
||||
}
|
||||
|
||||
static bool IsSize(const cricket::VideoFrame& frame,
|
||||
uint32 width, uint32 height) {
|
||||
return !IsNull(frame) &&
|
||||
frame.GetYPitch() >= static_cast<int32>(width) &&
|
||||
frame.GetUPitch() >= static_cast<int32>(width) / 2 &&
|
||||
frame.GetVPitch() >= static_cast<int32>(width) / 2 &&
|
||||
frame.GetWidth() == width && frame.GetHeight() == height;
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
return !IsNull(frame) && frame.GetYPitch() >= static_cast<int32_t>(width) &&
|
||||
frame.GetUPitch() >= static_cast<int32_t>(width) / 2 &&
|
||||
frame.GetVPitch() >= static_cast<int32_t>(width) / 2 &&
|
||||
frame.GetWidth() == width && frame.GetHeight() == height;
|
||||
}
|
||||
|
||||
static bool IsPlaneEqual(const std::string& name,
|
||||
const uint8* plane1, uint32 pitch1,
|
||||
const uint8* plane2, uint32 pitch2,
|
||||
uint32 width, uint32 height,
|
||||
const uint8_t* plane1,
|
||||
uint32_t pitch1,
|
||||
const uint8_t* plane2,
|
||||
uint32_t pitch2,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
int max_error) {
|
||||
const uint8* r1 = plane1;
|
||||
const uint8* r2 = plane2;
|
||||
for (uint32 y = 0; y < height; ++y) {
|
||||
for (uint32 x = 0; x < width; ++x) {
|
||||
const uint8_t* r1 = plane1;
|
||||
const uint8_t* r2 = plane2;
|
||||
for (uint32_t y = 0; y < height; ++y) {
|
||||
for (uint32_t x = 0; x < width; ++x) {
|
||||
if (abs(static_cast<int>(r1[x] - r2[x])) > max_error) {
|
||||
LOG(LS_INFO) << "IsPlaneEqual(" << name << "): pixel["
|
||||
<< x << "," << y << "] differs: "
|
||||
@ -433,28 +463,32 @@ class VideoFrameTest : public testing::Test {
|
||||
}
|
||||
|
||||
static bool IsEqual(const cricket::VideoFrame& frame,
|
||||
size_t width, size_t height,
|
||||
size_t pixel_width, size_t pixel_height,
|
||||
int64 time_stamp,
|
||||
const uint8* y, uint32 ypitch,
|
||||
const uint8* u, uint32 upitch,
|
||||
const uint8* v, uint32 vpitch,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t pixel_width,
|
||||
size_t pixel_height,
|
||||
int64_t time_stamp,
|
||||
const uint8_t* y,
|
||||
uint32_t ypitch,
|
||||
const uint8_t* u,
|
||||
uint32_t upitch,
|
||||
const uint8_t* v,
|
||||
uint32_t vpitch,
|
||||
int max_error) {
|
||||
return IsSize(frame,
|
||||
static_cast<uint32>(width),
|
||||
static_cast<uint32>(height)) &&
|
||||
frame.GetPixelWidth() == pixel_width &&
|
||||
frame.GetPixelHeight() == pixel_height &&
|
||||
frame.GetTimeStamp() == time_stamp &&
|
||||
IsPlaneEqual("y", frame.GetYPlane(), frame.GetYPitch(), y, ypitch,
|
||||
static_cast<uint32>(width),
|
||||
static_cast<uint32>(height), max_error) &&
|
||||
IsPlaneEqual("u", frame.GetUPlane(), frame.GetUPitch(), u, upitch,
|
||||
static_cast<uint32>((width + 1) / 2),
|
||||
static_cast<uint32>((height + 1) / 2), max_error) &&
|
||||
IsPlaneEqual("v", frame.GetVPlane(), frame.GetVPitch(), v, vpitch,
|
||||
static_cast<uint32>((width + 1) / 2),
|
||||
static_cast<uint32>((height + 1) / 2), max_error);
|
||||
return IsSize(frame, static_cast<uint32_t>(width),
|
||||
static_cast<uint32_t>(height)) &&
|
||||
frame.GetPixelWidth() == pixel_width &&
|
||||
frame.GetPixelHeight() == pixel_height &&
|
||||
frame.GetTimeStamp() == time_stamp &&
|
||||
IsPlaneEqual("y", frame.GetYPlane(), frame.GetYPitch(), y, ypitch,
|
||||
static_cast<uint32_t>(width),
|
||||
static_cast<uint32_t>(height), max_error) &&
|
||||
IsPlaneEqual("u", frame.GetUPlane(), frame.GetUPitch(), u, upitch,
|
||||
static_cast<uint32_t>((width + 1) / 2),
|
||||
static_cast<uint32_t>((height + 1) / 2), max_error) &&
|
||||
IsPlaneEqual("v", frame.GetVPlane(), frame.GetVPitch(), v, vpitch,
|
||||
static_cast<uint32_t>((width + 1) / 2),
|
||||
static_cast<uint32_t>((height + 1) / 2), max_error);
|
||||
}
|
||||
|
||||
static bool IsEqual(const cricket::VideoFrame& frame1,
|
||||
@ -512,11 +546,11 @@ class VideoFrameTest : public testing::Test {
|
||||
EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_I420,
|
||||
kWidth, kHeight, &frame));
|
||||
|
||||
const uint8* y = reinterpret_cast<uint8*>(ms.get()->GetBuffer());
|
||||
const uint8* u = y + kWidth * kHeight;
|
||||
const uint8* v = u + kWidth * kHeight / 4;
|
||||
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0,
|
||||
y, kWidth, u, kWidth / 2, v, kWidth / 2, 0));
|
||||
const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
|
||||
const uint8_t* u = y + kWidth * kHeight;
|
||||
const uint8_t* v = u + kWidth * kHeight / 4;
|
||||
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, y, kWidth, u,
|
||||
kWidth / 2, v, kWidth / 2, 0));
|
||||
}
|
||||
|
||||
// Test constructing an image from a YV12 buffer.
|
||||
@ -527,11 +561,11 @@ class VideoFrameTest : public testing::Test {
|
||||
EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YV12,
|
||||
kWidth, kHeight, &frame));
|
||||
|
||||
const uint8* y = reinterpret_cast<uint8*>(ms.get()->GetBuffer());
|
||||
const uint8* v = y + kWidth * kHeight;
|
||||
const uint8* u = v + kWidth * kHeight / 4;
|
||||
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0,
|
||||
y, kWidth, u, kWidth / 2, v, kWidth / 2, 0));
|
||||
const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
|
||||
const uint8_t* v = y + kWidth * kHeight;
|
||||
const uint8_t* u = v + kWidth * kHeight / 4;
|
||||
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, y, kWidth, u,
|
||||
kWidth / 2, v, kWidth / 2, 0));
|
||||
}
|
||||
|
||||
// Test constructing an image from a I422 buffer.
|
||||
@ -539,10 +573,10 @@ class VideoFrameTest : public testing::Test {
|
||||
T frame1, frame2;
|
||||
ASSERT_TRUE(LoadFrameNoRepeat(&frame1));
|
||||
size_t buf_size = kWidth * kHeight * 2;
|
||||
rtc::scoped_ptr<uint8[]> buf(new uint8[buf_size + kAlignment]);
|
||||
uint8* y = ALIGNP(buf.get(), kAlignment);
|
||||
uint8* u = y + kWidth * kHeight;
|
||||
uint8* v = u + (kWidth / 2) * kHeight;
|
||||
rtc::scoped_ptr<uint8_t[]> buf(new uint8_t[buf_size + kAlignment]);
|
||||
uint8_t* y = ALIGNP(buf.get(), kAlignment);
|
||||
uint8_t* u = y + kWidth * kHeight;
|
||||
uint8_t* v = u + (kWidth / 2) * kHeight;
|
||||
EXPECT_EQ(0, libyuv::I420ToI422(frame1.GetYPlane(), frame1.GetYPitch(),
|
||||
frame1.GetUPlane(), frame1.GetUPitch(),
|
||||
frame1.GetVPlane(), frame1.GetVPitch(),
|
||||
@ -560,8 +594,8 @@ class VideoFrameTest : public testing::Test {
|
||||
T frame1, frame2;
|
||||
ASSERT_TRUE(LoadFrameNoRepeat(&frame1));
|
||||
size_t buf_size = kWidth * kHeight * 2;
|
||||
rtc::scoped_ptr<uint8[]> buf(new uint8[buf_size + kAlignment]);
|
||||
uint8* yuy2 = ALIGNP(buf.get(), kAlignment);
|
||||
rtc::scoped_ptr<uint8_t[]> buf(new uint8_t[buf_size + kAlignment]);
|
||||
uint8_t* yuy2 = ALIGNP(buf.get(), kAlignment);
|
||||
EXPECT_EQ(0, libyuv::I420ToYUY2(frame1.GetYPlane(), frame1.GetYPitch(),
|
||||
frame1.GetUPlane(), frame1.GetUPitch(),
|
||||
frame1.GetVPlane(), frame1.GetVPitch(),
|
||||
@ -577,8 +611,8 @@ class VideoFrameTest : public testing::Test {
|
||||
T frame1, frame2;
|
||||
ASSERT_TRUE(LoadFrameNoRepeat(&frame1));
|
||||
size_t buf_size = kWidth * kHeight * 2;
|
||||
rtc::scoped_ptr<uint8[]> buf(new uint8[buf_size + kAlignment + 1]);
|
||||
uint8* yuy2 = ALIGNP(buf.get(), kAlignment) + 1;
|
||||
rtc::scoped_ptr<uint8_t[]> buf(new uint8_t[buf_size + kAlignment + 1]);
|
||||
uint8_t* yuy2 = ALIGNP(buf.get(), kAlignment) + 1;
|
||||
EXPECT_EQ(0, libyuv::I420ToYUY2(frame1.GetYPlane(), frame1.GetYPitch(),
|
||||
frame1.GetUPlane(), frame1.GetUPitch(),
|
||||
frame1.GetVPlane(), frame1.GetVPitch(),
|
||||
@ -734,8 +768,8 @@ class VideoFrameTest : public testing::Test {
|
||||
void ConstructRGB565() {
|
||||
T frame1, frame2;
|
||||
size_t out_size = kWidth * kHeight * 2;
|
||||
rtc::scoped_ptr<uint8[]> outbuf(new uint8[out_size + kAlignment]);
|
||||
uint8* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
rtc::scoped_ptr<uint8_t[]> outbuf(new uint8_t[out_size + kAlignment]);
|
||||
uint8_t* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
T frame;
|
||||
ASSERT_TRUE(LoadFrameNoRepeat(&frame1));
|
||||
EXPECT_EQ(out_size, frame1.ConvertToRgbBuffer(cricket::FOURCC_RGBP,
|
||||
@ -750,8 +784,8 @@ class VideoFrameTest : public testing::Test {
|
||||
void ConstructARGB1555() {
|
||||
T frame1, frame2;
|
||||
size_t out_size = kWidth * kHeight * 2;
|
||||
rtc::scoped_ptr<uint8[]> outbuf(new uint8[out_size + kAlignment]);
|
||||
uint8* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
rtc::scoped_ptr<uint8_t[]> outbuf(new uint8_t[out_size + kAlignment]);
|
||||
uint8_t* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
T frame;
|
||||
ASSERT_TRUE(LoadFrameNoRepeat(&frame1));
|
||||
EXPECT_EQ(out_size, frame1.ConvertToRgbBuffer(cricket::FOURCC_RGBO,
|
||||
@ -766,8 +800,8 @@ class VideoFrameTest : public testing::Test {
|
||||
void ConstructARGB4444() {
|
||||
T frame1, frame2;
|
||||
size_t out_size = kWidth * kHeight * 2;
|
||||
rtc::scoped_ptr<uint8[]> outbuf(new uint8[out_size + kAlignment]);
|
||||
uint8* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
rtc::scoped_ptr<uint8_t[]> outbuf(new uint8_t[out_size + kAlignment]);
|
||||
uint8_t* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
T frame;
|
||||
ASSERT_TRUE(LoadFrameNoRepeat(&frame1));
|
||||
EXPECT_EQ(out_size, frame1.ConvertToRgbBuffer(cricket::FOURCC_R444,
|
||||
@ -793,7 +827,7 @@ class VideoFrameTest : public testing::Test {
|
||||
EXPECT_TRUE(ret); \
|
||||
EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \
|
||||
kHeight, \
|
||||
reinterpret_cast<uint8*>(ms->GetBuffer()), \
|
||||
reinterpret_cast<uint8_t*>(ms->GetBuffer()), \
|
||||
data_size, 1, 1, 0, webrtc::kVideoRotation_0)); \
|
||||
int width_rotate = static_cast<int>(frame1.GetWidth()); \
|
||||
int height_rotate = static_cast<int>(frame1.GetHeight()); \
|
||||
@ -824,7 +858,7 @@ class VideoFrameTest : public testing::Test {
|
||||
EXPECT_TRUE(ret); \
|
||||
EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \
|
||||
kHeight, \
|
||||
reinterpret_cast<uint8*>(ms->GetBuffer()), \
|
||||
reinterpret_cast<uint8_t*>(ms->GetBuffer()), \
|
||||
data_size, 1, 1, 0, webrtc::kVideoRotation_0)); \
|
||||
int width_rotate = static_cast<int>(frame1.GetWidth()); \
|
||||
int height_rotate = static_cast<int>(frame1.GetHeight()); \
|
||||
@ -931,22 +965,21 @@ class VideoFrameTest : public testing::Test {
|
||||
// Test 1 pixel edge case image I420 buffer.
|
||||
void ConstructI4201Pixel() {
|
||||
T frame;
|
||||
uint8 pixel[3] = { 1, 2, 3 };
|
||||
uint8_t pixel[3] = {1, 2, 3};
|
||||
for (int i = 0; i < repeat_; ++i) {
|
||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel,
|
||||
sizeof(pixel), 1, 1, 0, webrtc::kVideoRotation_0));
|
||||
}
|
||||
const uint8* y = pixel;
|
||||
const uint8* u = y + 1;
|
||||
const uint8* v = u + 1;
|
||||
EXPECT_TRUE(IsEqual(frame, 1, 1, 1, 1, 0,
|
||||
y, 1, u, 1, v, 1, 0));
|
||||
const uint8_t* y = pixel;
|
||||
const uint8_t* u = y + 1;
|
||||
const uint8_t* v = u + 1;
|
||||
EXPECT_TRUE(IsEqual(frame, 1, 1, 1, 1, 0, y, 1, u, 1, v, 1, 0));
|
||||
}
|
||||
|
||||
// Test 5 pixel edge case image.
|
||||
void ConstructI4205Pixel() {
|
||||
T frame;
|
||||
uint8 pixels5x5[5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2];
|
||||
uint8_t pixels5x5[5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2];
|
||||
memset(pixels5x5, 1, 5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2);
|
||||
for (int i = 0; i < repeat_; ++i) {
|
||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 5, 5, 5, 5, pixels5x5,
|
||||
@ -963,7 +996,7 @@ class VideoFrameTest : public testing::Test {
|
||||
// Test 1 pixel edge case image ARGB buffer.
|
||||
void ConstructARGB1Pixel() {
|
||||
T frame;
|
||||
uint8 pixel[4] = { 64, 128, 192, 255 };
|
||||
uint8_t pixel[4] = {64, 128, 192, 255};
|
||||
for (int i = 0; i < repeat_; ++i) {
|
||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 1, 1, 1, 1, pixel,
|
||||
sizeof(pixel), 1, 1, 0,
|
||||
@ -971,8 +1004,8 @@ class VideoFrameTest : public testing::Test {
|
||||
}
|
||||
// Convert back to ARGB.
|
||||
size_t out_size = 4;
|
||||
rtc::scoped_ptr<uint8[]> outbuf(new uint8[out_size + kAlignment]);
|
||||
uint8* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
rtc::scoped_ptr<uint8_t[]> outbuf(new uint8_t[out_size + kAlignment]);
|
||||
uint8_t* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
|
||||
EXPECT_EQ(out_size, frame.ConvertToRgbBuffer(cricket::FOURCC_ARGB,
|
||||
out,
|
||||
@ -990,16 +1023,16 @@ class VideoFrameTest : public testing::Test {
|
||||
// Test Black, White and Grey pixels.
|
||||
void ConstructARGBBlackWhitePixel() {
|
||||
T frame;
|
||||
uint8 pixel[10 * 4] = { 0, 0, 0, 255, // Black.
|
||||
0, 0, 0, 255,
|
||||
64, 64, 64, 255, // Dark Grey.
|
||||
64, 64, 64, 255,
|
||||
128, 128, 128, 255, // Grey.
|
||||
128, 128, 128, 255,
|
||||
196, 196, 196, 255, // Light Grey.
|
||||
196, 196, 196, 255,
|
||||
255, 255, 255, 255, // White.
|
||||
255, 255, 255, 255 };
|
||||
uint8_t pixel[10 * 4] = {0, 0, 0, 255, // Black.
|
||||
0, 0, 0, 255, // Black.
|
||||
64, 64, 64, 255, // Dark Grey.
|
||||
64, 64, 64, 255, // Dark Grey.
|
||||
128, 128, 128, 255, // Grey.
|
||||
128, 128, 128, 255, // Grey.
|
||||
196, 196, 196, 255, // Light Grey.
|
||||
196, 196, 196, 255, // Light Grey.
|
||||
255, 255, 255, 255, // White.
|
||||
255, 255, 255, 255}; // White.
|
||||
|
||||
for (int i = 0; i < repeat_; ++i) {
|
||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 10, 1, 10, 1, pixel,
|
||||
@ -1008,8 +1041,8 @@ class VideoFrameTest : public testing::Test {
|
||||
}
|
||||
// Convert back to ARGB
|
||||
size_t out_size = 10 * 4;
|
||||
rtc::scoped_ptr<uint8[]> outbuf(new uint8[out_size + kAlignment]);
|
||||
uint8* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
rtc::scoped_ptr<uint8_t[]> outbuf(new uint8_t[out_size + kAlignment]);
|
||||
uint8_t* out = ALIGNP(outbuf.get(), kAlignment);
|
||||
|
||||
EXPECT_EQ(out_size, frame.ConvertToRgbBuffer(cricket::FOURCC_ARGB,
|
||||
out,
|
||||
@ -1131,12 +1164,16 @@ class VideoFrameTest : public testing::Test {
|
||||
}
|
||||
|
||||
// Test constructing an image from an I420 MJPG buffer.
|
||||
void ValidateFrame(const char* name, uint32 fourcc, int data_adjust,
|
||||
int size_adjust, bool expected_result) {
|
||||
void ValidateFrame(const char* name,
|
||||
uint32_t fourcc,
|
||||
int data_adjust,
|
||||
int size_adjust,
|
||||
bool expected_result) {
|
||||
T frame;
|
||||
rtc::scoped_ptr<rtc::MemoryStream> ms(LoadSample(name));
|
||||
ASSERT_TRUE(ms.get() != NULL);
|
||||
const uint8* sample = reinterpret_cast<const uint8*>(ms.get()->GetBuffer());
|
||||
const uint8_t* sample =
|
||||
reinterpret_cast<const uint8_t*>(ms.get()->GetBuffer());
|
||||
size_t sample_size;
|
||||
ms->GetSize(&sample_size);
|
||||
// Optional adjust size to test invalid size.
|
||||
@ -1144,9 +1181,9 @@ class VideoFrameTest : public testing::Test {
|
||||
|
||||
// Allocate a buffer with end page aligned.
|
||||
const int kPadToHeapSized = 16 * 1024 * 1024;
|
||||
rtc::scoped_ptr<uint8[]> page_buffer(
|
||||
new uint8[((data_size + kPadToHeapSized + 4095) & ~4095)]);
|
||||
uint8* data_ptr = page_buffer.get();
|
||||
rtc::scoped_ptr<uint8_t[]> page_buffer(
|
||||
new uint8_t[((data_size + kPadToHeapSized + 4095) & ~4095)]);
|
||||
uint8_t* data_ptr = page_buffer.get();
|
||||
if (!data_ptr) {
|
||||
LOG(LS_WARNING) << "Failed to allocate memory for ValidateFrame test.";
|
||||
EXPECT_FALSE(expected_result); // NULL is okay if failure was expected.
|
||||
@ -1383,9 +1420,9 @@ class VideoFrameTest : public testing::Test {
|
||||
EXPECT_TRUE(IsBlack(frame1));
|
||||
EXPECT_TRUE(IsEqual(frame1, frame2, 0));
|
||||
EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, kWidth, kHeight, kWidth,
|
||||
kHeight, reinterpret_cast<uint8*>(ms->GetBuffer()),
|
||||
data_size, 1, 1, 0, rotation,
|
||||
apply_rotation));
|
||||
kHeight,
|
||||
reinterpret_cast<uint8_t*>(ms->GetBuffer()),
|
||||
data_size, 1, 1, 0, rotation, apply_rotation));
|
||||
if (apply_rotation)
|
||||
EXPECT_EQ(webrtc::kVideoRotation_0, frame1.GetVideoRotation());
|
||||
else
|
||||
@ -1419,23 +1456,32 @@ class VideoFrameTest : public testing::Test {
|
||||
enum ToFrom { TO, FROM };
|
||||
|
||||
// Helper function for test converting from I420 to packed formats.
|
||||
inline void ConvertToBuffer(int bpp, int rowpad, bool invert, ToFrom to_from,
|
||||
int error, uint32 fourcc,
|
||||
int (*RGBToI420)(const uint8* src_frame, int src_stride_frame,
|
||||
uint8* dst_y, int dst_stride_y,
|
||||
uint8* dst_u, int dst_stride_u,
|
||||
uint8* dst_v, int dst_stride_v,
|
||||
int width, int height)) {
|
||||
inline void ConvertToBuffer(int bpp,
|
||||
int rowpad,
|
||||
bool invert,
|
||||
ToFrom to_from,
|
||||
int error,
|
||||
uint32_t fourcc,
|
||||
int (*RGBToI420)(const uint8_t* src_frame,
|
||||
int src_stride_frame,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height)) {
|
||||
T frame1, frame2;
|
||||
int repeat_to = (to_from == TO) ? repeat_ : 1;
|
||||
int repeat_from = (to_from == FROM) ? repeat_ : 1;
|
||||
|
||||
int astride = kWidth * bpp + rowpad;
|
||||
size_t out_size = astride * kHeight;
|
||||
rtc::scoped_ptr<uint8[]> outbuf(new uint8[out_size + kAlignment + 1]);
|
||||
rtc::scoped_ptr<uint8_t[]> outbuf(new uint8_t[out_size + kAlignment + 1]);
|
||||
memset(outbuf.get(), 0, out_size + kAlignment + 1);
|
||||
uint8* outtop = ALIGNP(outbuf.get(), kAlignment);
|
||||
uint8* out = outtop;
|
||||
uint8_t* outtop = ALIGNP(outbuf.get(), kAlignment);
|
||||
uint8_t* out = outtop;
|
||||
int stride = astride;
|
||||
if (invert) {
|
||||
out += (kHeight - 1) * stride; // Point to last row.
|
||||
@ -1750,10 +1796,10 @@ class VideoFrameTest : public testing::Test {
|
||||
void ConvertToI422Buffer() {
|
||||
T frame1, frame2;
|
||||
size_t out_size = kWidth * kHeight * 2;
|
||||
rtc::scoped_ptr<uint8[]> buf(new uint8[out_size + kAlignment]);
|
||||
uint8* y = ALIGNP(buf.get(), kAlignment);
|
||||
uint8* u = y + kWidth * kHeight;
|
||||
uint8* v = u + (kWidth / 2) * kHeight;
|
||||
rtc::scoped_ptr<uint8_t[]> buf(new uint8_t[out_size + kAlignment]);
|
||||
uint8_t* y = ALIGNP(buf.get(), kAlignment);
|
||||
uint8_t* u = y + kWidth * kHeight;
|
||||
uint8_t* v = u + (kWidth / 2) * kHeight;
|
||||
ASSERT_TRUE(LoadFrameNoRepeat(&frame1));
|
||||
for (int i = 0; i < repeat_; ++i) {
|
||||
EXPECT_EQ(0, libyuv::I420ToI422(frame1.GetYPlane(), frame1.GetYPitch(),
|
||||
@ -1816,7 +1862,7 @@ class VideoFrameTest : public testing::Test {
|
||||
ASSERT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_I420, kWidth, kHeight,
|
||||
&frame));
|
||||
size_t out_size = kWidth * kHeight * 3 / 2;
|
||||
rtc::scoped_ptr<uint8[]> out(new uint8[out_size]);
|
||||
rtc::scoped_ptr<uint8_t[]> out(new uint8_t[out_size]);
|
||||
for (int i = 0; i < repeat_; ++i) {
|
||||
EXPECT_EQ(out_size, frame.CopyToBuffer(out.get(), out_size));
|
||||
}
|
||||
@ -1864,9 +1910,9 @@ class VideoFrameTest : public testing::Test {
|
||||
|
||||
void CopyToBuffer1Pixel() {
|
||||
size_t out_size = 3;
|
||||
rtc::scoped_ptr<uint8[]> out(new uint8[out_size + 1]);
|
||||
rtc::scoped_ptr<uint8_t[]> out(new uint8_t[out_size + 1]);
|
||||
memset(out.get(), 0xfb, out_size + 1); // Fill buffer
|
||||
uint8 pixel[3] = { 1, 2, 3 };
|
||||
uint8_t pixel[3] = {1, 2, 3};
|
||||
T frame;
|
||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel,
|
||||
sizeof(pixel), 1, 1, 0,
|
||||
|
||||
@ -55,9 +55,9 @@ YuvFrameGenerator::YuvFrameGenerator(int width, int height,
|
||||
int size = width_ * height_;
|
||||
int qsize = size / 4;
|
||||
frame_data_size_ = size + 2 * qsize;
|
||||
y_data_ = new uint8[size];
|
||||
u_data_ = new uint8[qsize];
|
||||
v_data_ = new uint8[qsize];
|
||||
y_data_ = new uint8_t[size];
|
||||
u_data_ = new uint8_t[qsize];
|
||||
v_data_ = new uint8_t[qsize];
|
||||
if (enable_barcode) {
|
||||
ASSERT(width_ >= kBarcodeBackgroundWidth);
|
||||
ASSERT(height_>= kBarcodeBackgroundHeight);
|
||||
@ -75,8 +75,8 @@ YuvFrameGenerator::~YuvFrameGenerator() {
|
||||
delete v_data_;
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::GenerateNextFrame(uint8* frame_buffer,
|
||||
int32 barcode_value) {
|
||||
void YuvFrameGenerator::GenerateNextFrame(uint8_t* frame_buffer,
|
||||
int32_t barcode_value) {
|
||||
int size = width_ * height_;
|
||||
int qsize = size / 4;
|
||||
memset(y_data_, 0, size);
|
||||
@ -104,7 +104,7 @@ void YuvFrameGenerator::GenerateNextFrame(uint8* frame_buffer,
|
||||
frame_index_ = (frame_index_ + 1) & 0x0000FFFF;
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawLandscape(uint8 *p, int w, int h) {
|
||||
void YuvFrameGenerator::DrawLandscape(uint8_t* p, int w, int h) {
|
||||
int x, y;
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < w; x++) {
|
||||
@ -117,7 +117,7 @@ void YuvFrameGenerator::DrawLandscape(uint8 *p, int w, int h) {
|
||||
}
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawGradientX(uint8 *p, int w, int h) {
|
||||
void YuvFrameGenerator::DrawGradientX(uint8_t* p, int w, int h) {
|
||||
int x, y;
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < w; x++) {
|
||||
@ -126,7 +126,7 @@ void YuvFrameGenerator::DrawGradientX(uint8 *p, int w, int h) {
|
||||
}
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawGradientY(uint8 *p, int w, int h) {
|
||||
void YuvFrameGenerator::DrawGradientY(uint8_t* p, int w, int h) {
|
||||
int x, y;
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < w; x++) {
|
||||
@ -135,7 +135,7 @@ void YuvFrameGenerator::DrawGradientY(uint8 *p, int w, int h) {
|
||||
}
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawMovingLineX(uint8 *p, int w, int h, int n) {
|
||||
void YuvFrameGenerator::DrawMovingLineX(uint8_t* p, int w, int h, int n) {
|
||||
int x, y;
|
||||
x = n % (w * 2);
|
||||
if (x >= w) x = w + w - x - 1;
|
||||
@ -144,7 +144,7 @@ void YuvFrameGenerator::DrawMovingLineX(uint8 *p, int w, int h, int n) {
|
||||
}
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawMovingLineY(uint8 *p, int w, int h, int n) {
|
||||
void YuvFrameGenerator::DrawMovingLineY(uint8_t* p, int w, int h, int n) {
|
||||
int x, y;
|
||||
y = n % (h * 2);
|
||||
if (y >= h) y = h + h - y - 1;
|
||||
@ -153,7 +153,7 @@ void YuvFrameGenerator::DrawMovingLineY(uint8 *p, int w, int h, int n) {
|
||||
}
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawBouncingCube(uint8 *p, int w, int h, int n) {
|
||||
void YuvFrameGenerator::DrawBouncingCube(uint8_t* p, int w, int h, int n) {
|
||||
int x, y, pw, ph, px, py;
|
||||
pw = w / 16;
|
||||
ph = h / 16;
|
||||
@ -181,7 +181,7 @@ void YuvFrameGenerator::GetBarcodeBounds(int* top, int* left,
|
||||
*height = kBarcodeBackgroundHeight;
|
||||
}
|
||||
|
||||
static void ComputeBarcodeDigits(uint32 value, std::stringstream* result) {
|
||||
static void ComputeBarcodeDigits(uint32_t value, std::stringstream* result) {
|
||||
// Serialize |value| as 7-char string, padded with 0's to the left.
|
||||
result->width(kBarcodeMaxEncodableDigits);
|
||||
result->fill('0');
|
||||
@ -193,10 +193,10 @@ static void ComputeBarcodeDigits(uint32 value, std::stringstream* result) {
|
||||
for (int pos = 1; pos <= kBarcodeMaxEncodableDigits; pos++) {
|
||||
char next_char;
|
||||
result->get(next_char);
|
||||
uint8 digit = next_char - '0';
|
||||
uint8_t digit = next_char - '0';
|
||||
sum += digit * (pos % 2 ? 3 : 1);
|
||||
}
|
||||
uint8 check_digit = sum % 10;
|
||||
uint8_t check_digit = sum % 10;
|
||||
if (check_digit != 0) {
|
||||
check_digit = 10 - check_digit;
|
||||
}
|
||||
@ -205,7 +205,7 @@ static void ComputeBarcodeDigits(uint32 value, std::stringstream* result) {
|
||||
result->seekg(0);
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawBarcode(uint32 value) {
|
||||
void YuvFrameGenerator::DrawBarcode(uint32_t value) {
|
||||
std::stringstream value_str_stream;
|
||||
ComputeBarcodeDigits(value, &value_str_stream);
|
||||
|
||||
@ -234,7 +234,7 @@ void YuvFrameGenerator::DrawBarcode(uint32 value) {
|
||||
if (pos++ == 4) {
|
||||
x = DrawMiddleGuardBars(x, y, kBarcodeGuardBarHeight);
|
||||
}
|
||||
uint8 digit = next_char - '0';
|
||||
uint8_t digit = next_char - '0';
|
||||
x = DrawEanEncodedDigit(digit, x, y, kBarcodeNormalBarHeight, pos > 4);
|
||||
}
|
||||
x = DrawSideGuardBars(x, y, kBarcodeGuardBarHeight);
|
||||
@ -259,15 +259,15 @@ int YuvFrameGenerator::DrawSideGuardBars(int x, int y, int height) {
|
||||
// which bars are black (1) and which are blank (0). These are for the L-code
|
||||
// only. R-code values are bitwise negation of these. Reference:
|
||||
// http://en.wikipedia.org/wiki/European_Article_Number#Binary_encoding_of_data_digits_into_EAN-13_barcode // NOLINT
|
||||
const uint8 kEanEncodings[] = { 13, 25, 19, 61, 35, 49, 47, 59, 55, 11 };
|
||||
const uint8_t kEanEncodings[] = {13, 25, 19, 61, 35, 49, 47, 59, 55, 11};
|
||||
|
||||
int YuvFrameGenerator::DrawEanEncodedDigit(int digit, int x, int y,
|
||||
int height, bool flip) {
|
||||
uint8 ean_encoding = kEanEncodings[digit];
|
||||
uint8_t ean_encoding = kEanEncodings[digit];
|
||||
if (flip) {
|
||||
ean_encoding = ~ean_encoding;
|
||||
}
|
||||
uint8 mask = 0x40;
|
||||
uint8_t mask = 0x40;
|
||||
for (int i = 6; i >= 0; i--, mask >>= 1) {
|
||||
if (ean_encoding & mask) {
|
||||
DrawBlockRectangle(y_data_, x, y, kUnitBarSize, height, width_, 0);
|
||||
@ -277,8 +277,13 @@ int YuvFrameGenerator::DrawEanEncodedDigit(int digit, int x, int y,
|
||||
return x;
|
||||
}
|
||||
|
||||
void YuvFrameGenerator::DrawBlockRectangle(uint8* p,
|
||||
int x_start, int y_start, int width, int height, int pitch, uint8 value) {
|
||||
void YuvFrameGenerator::DrawBlockRectangle(uint8_t* p,
|
||||
int x_start,
|
||||
int y_start,
|
||||
int width,
|
||||
int height,
|
||||
int pitch,
|
||||
uint8_t value) {
|
||||
for (int x = x_start; x < x_start + width; x++) {
|
||||
for (int y = y_start; y < y_start + height; y++) {
|
||||
p[x + y * pitch] = value;
|
||||
|
||||
@ -48,8 +48,8 @@ class YuvFrameGenerator {
|
||||
public:
|
||||
// Constructs a frame-generator that produces frames of size |width|x|height|.
|
||||
// If |enable_barcode| is specified, barcodes can be included in the frames
|
||||
// when calling |GenerateNextFrame(uint8*, uint32)|. If |enable_barcode| is
|
||||
// |true| then |width|x|height| should be at least 160x100; otherwise this
|
||||
// when calling |GenerateNextFrame(uint8_t*, uint32_t)|. If |enable_barcode|
|
||||
// is |true| then |width|x|height| should be at least 160x100; otherwise this
|
||||
// constructor will abort.
|
||||
YuvFrameGenerator(int width, int height, bool enable_barcode);
|
||||
~YuvFrameGenerator();
|
||||
@ -61,7 +61,7 @@ class YuvFrameGenerator {
|
||||
// into a barcode in the frame. The value should in the range:
|
||||
// [0..9,999,999]. If the value exceeds this range or barcodes were not
|
||||
// requested in the constructor, this function will abort.
|
||||
void GenerateNextFrame(uint8* frame_buffer, int32 barcode_value);
|
||||
void GenerateNextFrame(uint8_t* frame_buffer, int32_t barcode_value);
|
||||
|
||||
int GetHeight() { return height_; }
|
||||
int GetWidth() { return width_; }
|
||||
@ -72,28 +72,33 @@ class YuvFrameGenerator {
|
||||
void GetBarcodeBounds(int* top, int* left, int* width, int* height);
|
||||
|
||||
private:
|
||||
void DrawLandscape(uint8 *p, int w, int h);
|
||||
void DrawGradientX(uint8 *p, int w, int h);
|
||||
void DrawGradientY(uint8 *p, int w, int h);
|
||||
void DrawMovingLineX(uint8 *p, int w, int h, int n);
|
||||
void DrawMovingLineY(uint8 *p, int w, int h, int n);
|
||||
void DrawBouncingCube(uint8 *p, int w, int h, int n);
|
||||
void DrawLandscape(uint8_t* p, int w, int h);
|
||||
void DrawGradientX(uint8_t* p, int w, int h);
|
||||
void DrawGradientY(uint8_t* p, int w, int h);
|
||||
void DrawMovingLineX(uint8_t* p, int w, int h, int n);
|
||||
void DrawMovingLineY(uint8_t* p, int w, int h, int n);
|
||||
void DrawBouncingCube(uint8_t* p, int w, int h, int n);
|
||||
|
||||
void DrawBarcode(uint32 value);
|
||||
void DrawBarcode(uint32_t value);
|
||||
int DrawSideGuardBars(int x, int y, int height);
|
||||
int DrawMiddleGuardBars(int x, int y, int height);
|
||||
int DrawEanEncodedDigit(int digit, int x, int y, int height, bool r_code);
|
||||
void DrawBlockRectangle(uint8* p, int x_start, int y_start,
|
||||
int width, int height, int pitch, uint8 value);
|
||||
void DrawBlockRectangle(uint8_t* p,
|
||||
int x_start,
|
||||
int y_start,
|
||||
int width,
|
||||
int height,
|
||||
int pitch,
|
||||
uint8_t value);
|
||||
|
||||
private:
|
||||
int width_;
|
||||
int height_;
|
||||
int frame_index_;
|
||||
int frame_data_size_;
|
||||
uint8* y_data_;
|
||||
uint8* u_data_;
|
||||
uint8* v_data_;
|
||||
uint8_t* y_data_;
|
||||
uint8_t* u_data_;
|
||||
uint8_t* v_data_;
|
||||
|
||||
int barcode_start_x_;
|
||||
int barcode_start_y_;
|
||||
|
||||
@ -116,7 +116,7 @@ bool CarbonVideoRenderer::SetSize(int width, int height, int reserved) {
|
||||
rtc::CritScope cs(&image_crit_);
|
||||
image_width_ = width;
|
||||
image_height_ = height;
|
||||
image_.reset(new uint8[width * height * 4]);
|
||||
image_.reset(new uint8_t[width * height * 4]);
|
||||
memset(image_.get(), 255, width * height * 4);
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -59,7 +59,7 @@ class CarbonVideoRenderer : public VideoRenderer {
|
||||
static OSStatus DrawEventHandler(EventHandlerCallRef handler,
|
||||
EventRef event,
|
||||
void* data);
|
||||
rtc::scoped_ptr<uint8[]> image_;
|
||||
rtc::scoped_ptr<uint8_t[]> image_;
|
||||
rtc::CriticalSection image_crit_;
|
||||
int image_width_;
|
||||
int image_height_;
|
||||
|
||||
@ -60,7 +60,7 @@ bool VideoRecorder::RecordFrame(const CapturedFrame& frame) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 size = 0;
|
||||
uint32_t size = 0;
|
||||
if (!frame.GetDataSize(&size)) {
|
||||
LOG(LS_ERROR) << "Unable to calculate the data size of the frame";
|
||||
return false;
|
||||
@ -158,7 +158,7 @@ class FileVideoCapturer::FileReadThread
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Implementation of class FileVideoCapturer
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
static const int64 kNumNanoSecsPerMilliSec = 1000000;
|
||||
static const int64_t kNumNanoSecsPerMilliSec = 1000000;
|
||||
const char* FileVideoCapturer::kVideoFileDevicePrefix = "video-file:";
|
||||
|
||||
FileVideoCapturer::FileVideoCapturer()
|
||||
@ -267,7 +267,7 @@ void FileVideoCapturer::Stop() {
|
||||
SetCaptureFormat(NULL);
|
||||
}
|
||||
|
||||
bool FileVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
|
||||
bool FileVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
|
||||
if (!fourccs) {
|
||||
return false;
|
||||
}
|
||||
@ -296,15 +296,15 @@ rtc::StreamResult FileVideoCapturer::ReadFrameHeader(
|
||||
return rtc::SR_EOS;
|
||||
}
|
||||
rtc::ByteBuffer buffer(header, CapturedFrame::kFrameHeaderSize);
|
||||
buffer.ReadUInt32(reinterpret_cast<uint32*>(&frame->width));
|
||||
buffer.ReadUInt32(reinterpret_cast<uint32*>(&frame->height));
|
||||
buffer.ReadUInt32(reinterpret_cast<uint32_t*>(&frame->width));
|
||||
buffer.ReadUInt32(reinterpret_cast<uint32_t*>(&frame->height));
|
||||
buffer.ReadUInt32(&frame->fourcc);
|
||||
buffer.ReadUInt32(&frame->pixel_width);
|
||||
buffer.ReadUInt32(&frame->pixel_height);
|
||||
// Elapsed time is deprecated.
|
||||
uint64 dummy_elapsed_time;
|
||||
uint64_t dummy_elapsed_time;
|
||||
buffer.ReadUInt64(&dummy_elapsed_time);
|
||||
buffer.ReadUInt64(reinterpret_cast<uint64*>(&frame->time_stamp));
|
||||
buffer.ReadUInt64(reinterpret_cast<uint64_t*>(&frame->time_stamp));
|
||||
buffer.ReadUInt32(&frame->data_size);
|
||||
}
|
||||
|
||||
@ -313,12 +313,12 @@ rtc::StreamResult FileVideoCapturer::ReadFrameHeader(
|
||||
|
||||
// Executed in the context of FileReadThread.
|
||||
bool FileVideoCapturer::ReadFrame(bool first_frame, int* wait_time_ms) {
|
||||
uint32 start_read_time_ms = rtc::Time();
|
||||
uint32_t start_read_time_ms = rtc::Time();
|
||||
|
||||
// 1. Signal the previously read frame to downstream.
|
||||
if (!first_frame) {
|
||||
captured_frame_.time_stamp = kNumNanoSecsPerMilliSec *
|
||||
static_cast<int64>(start_read_time_ms);
|
||||
captured_frame_.time_stamp =
|
||||
kNumNanoSecsPerMilliSec * static_cast<int64_t>(start_read_time_ms);
|
||||
SignalFrameCaptured(this, &captured_frame_);
|
||||
}
|
||||
|
||||
@ -367,10 +367,10 @@ bool FileVideoCapturer::ReadFrame(bool first_frame, int* wait_time_ms) {
|
||||
// control the rate; otherwise, we use the timestamp in the file to control
|
||||
// the rate.
|
||||
if (!first_frame && !ignore_framerate_) {
|
||||
int64 interval_ns =
|
||||
GetCaptureFormat()->interval > VideoFormat::kMinimumInterval ?
|
||||
GetCaptureFormat()->interval :
|
||||
captured_frame_.time_stamp - last_frame_timestamp_ns_;
|
||||
int64_t interval_ns =
|
||||
GetCaptureFormat()->interval > VideoFormat::kMinimumInterval
|
||||
? GetCaptureFormat()->interval
|
||||
: captured_frame_.time_stamp - last_frame_timestamp_ns_;
|
||||
int interval_ms = static_cast<int>(interval_ns / kNumNanoSecsPerMilliSec);
|
||||
interval_ms -= rtc::Time() - start_read_time_ms;
|
||||
if (interval_ms > 0) {
|
||||
|
||||
@ -122,7 +122,7 @@ class FileVideoCapturer : public VideoCapturer {
|
||||
|
||||
protected:
|
||||
// Override virtual methods of parent class VideoCapturer.
|
||||
virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs);
|
||||
virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs);
|
||||
|
||||
// Read the frame header from the file stream, video_file_.
|
||||
rtc::StreamResult ReadFrameHeader(CapturedFrame* frame);
|
||||
@ -146,10 +146,10 @@ class FileVideoCapturer : public VideoCapturer {
|
||||
rtc::FileStream video_file_;
|
||||
CapturedFrame captured_frame_;
|
||||
// The number of bytes allocated buffer for captured_frame_.data.
|
||||
uint32 frame_buffer_size_;
|
||||
uint32_t frame_buffer_size_;
|
||||
FileReadThread* file_read_thread_;
|
||||
int repeat_; // How many times to repeat the file.
|
||||
int64 last_frame_timestamp_ns_; // Timestamp of last read frame.
|
||||
int64_t last_frame_timestamp_ns_; // Timestamp of last read frame.
|
||||
bool ignore_framerate_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(FileVideoCapturer);
|
||||
|
||||
@ -100,7 +100,7 @@ class GdiVideoRenderer::VideoWindow : public rtc::Win32Window {
|
||||
void OnRenderFrame(const VideoFrame* frame);
|
||||
|
||||
BITMAPINFO bmi_;
|
||||
rtc::scoped_ptr<uint8[]> image_;
|
||||
rtc::scoped_ptr<uint8_t[]> image_;
|
||||
rtc::scoped_ptr<WindowThread> window_thread_;
|
||||
// The initial position of the window.
|
||||
int initial_x_;
|
||||
@ -123,7 +123,7 @@ GdiVideoRenderer::VideoWindow::VideoWindow(
|
||||
bmi_.bmiHeader.biHeight = -height;
|
||||
bmi_.bmiHeader.biSizeImage = width * height * 4;
|
||||
|
||||
image_.reset(new uint8[bmi_.bmiHeader.biSizeImage]);
|
||||
image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]);
|
||||
}
|
||||
|
||||
GdiVideoRenderer::VideoWindow::~VideoWindow() {
|
||||
@ -237,7 +237,7 @@ void GdiVideoRenderer::VideoWindow::OnSize(int width, int height,
|
||||
bmi_.bmiHeader.biWidth = width;
|
||||
bmi_.bmiHeader.biHeight = -height;
|
||||
bmi_.bmiHeader.biSizeImage = width * height * 4;
|
||||
image_.reset(new uint8[bmi_.bmiHeader.biSizeImage]);
|
||||
image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ bool GtkVideoRenderer::SetSize(int width, int height, int reserved) {
|
||||
return false;
|
||||
}
|
||||
|
||||
image_.reset(new uint8[width * height * 4]);
|
||||
image_.reset(new uint8_t[width * height * 4]);
|
||||
gtk_widget_set_size_request(draw_area_, width, height);
|
||||
|
||||
width_ = width;
|
||||
@ -153,7 +153,7 @@ bool GtkVideoRenderer::Initialize(int width, int height) {
|
||||
gtk_widget_show_all(window_);
|
||||
gtk_window_move(GTK_WINDOW(window_), initial_x_, initial_y_);
|
||||
|
||||
image_.reset(new uint8[width * height * 4]);
|
||||
image_.reset(new uint8_t[width * height * 4]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ class GtkVideoRenderer : public VideoRenderer {
|
||||
// Check if the window has been closed.
|
||||
bool IsClosed() const;
|
||||
|
||||
rtc::scoped_ptr<uint8[]> image_;
|
||||
rtc::scoped_ptr<uint8_t[]> image_;
|
||||
GtkWidget* window_;
|
||||
GtkWidget* draw_area_;
|
||||
// The initial position of the window.
|
||||
|
||||
@ -60,9 +60,9 @@ class LinuxDeviceWatcher
|
||||
virtual void Stop();
|
||||
|
||||
private:
|
||||
virtual uint32 GetRequestedEvents();
|
||||
virtual void OnPreEvent(uint32 ff);
|
||||
virtual void OnEvent(uint32 ff, int err);
|
||||
virtual uint32_t GetRequestedEvents();
|
||||
virtual void OnPreEvent(uint32_t ff);
|
||||
virtual void OnEvent(uint32_t ff, int err);
|
||||
virtual int GetDescriptor();
|
||||
virtual bool IsDescriptorClosed();
|
||||
|
||||
@ -368,15 +368,15 @@ void LinuxDeviceWatcher::Stop() {
|
||||
libudev_.Unload();
|
||||
}
|
||||
|
||||
uint32 LinuxDeviceWatcher::GetRequestedEvents() {
|
||||
uint32_t LinuxDeviceWatcher::GetRequestedEvents() {
|
||||
return rtc::DE_READ;
|
||||
}
|
||||
|
||||
void LinuxDeviceWatcher::OnPreEvent(uint32 ff) {
|
||||
void LinuxDeviceWatcher::OnPreEvent(uint32_t ff) {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
void LinuxDeviceWatcher::OnEvent(uint32 ff, int err) {
|
||||
void LinuxDeviceWatcher::OnEvent(uint32_t ff, int err) {
|
||||
udev_device* device = libudev_.udev_monitor_receive_device()(udev_monitor_);
|
||||
if (!device) {
|
||||
// Probably the socket connection to the udev daemon was terminated (perhaps
|
||||
|
||||
@ -53,10 +53,10 @@ bool MobileDeviceManager::GetVideoCaptureDevices(std::vector<Device>* devs) {
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
uint32 num_cams = info->NumberOfDevices();
|
||||
uint32_t num_cams = info->NumberOfDevices();
|
||||
char id[256];
|
||||
char name[256];
|
||||
for (uint32 i = 0; i < num_cams; ++i) {
|
||||
for (uint32_t i = 0; i < num_cams; ++i) {
|
||||
if (info->GetDeviceName(i, name, arraysize(name), id, arraysize(id)))
|
||||
continue;
|
||||
devs->push_back(Device(name, id));
|
||||
|
||||
@ -140,7 +140,7 @@ CaptureState YuvFramesCapturer::Start(const VideoFormat& capture_format) {
|
||||
SetCaptureFormat(&capture_format);
|
||||
|
||||
barcode_reference_timestamp_millis_ =
|
||||
static_cast<int64>(rtc::Time()) * 1000;
|
||||
static_cast<int64_t>(rtc::Time()) * 1000;
|
||||
// Create a thread to generate frames.
|
||||
frames_generator_thread = new YuvFramesThread(this);
|
||||
bool ret = frames_generator_thread->Start();
|
||||
@ -166,7 +166,7 @@ void YuvFramesCapturer::Stop() {
|
||||
SetCaptureFormat(NULL);
|
||||
}
|
||||
|
||||
bool YuvFramesCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
|
||||
bool YuvFramesCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) {
|
||||
if (!fourccs) {
|
||||
return false;
|
||||
}
|
||||
@ -180,21 +180,20 @@ void YuvFramesCapturer::ReadFrame(bool first_frame) {
|
||||
if (!first_frame) {
|
||||
SignalFrameCaptured(this, &captured_frame_);
|
||||
}
|
||||
uint8* buffer = new uint8[frame_data_size_];
|
||||
uint8_t* buffer = new uint8_t[frame_data_size_];
|
||||
frame_generator_->GenerateNextFrame(buffer, GetBarcodeValue());
|
||||
frame_index_++;
|
||||
memmove(captured_frame_.data, buffer, frame_data_size_);
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
||||
int32 YuvFramesCapturer::GetBarcodeValue() {
|
||||
int32_t YuvFramesCapturer::GetBarcodeValue() {
|
||||
if (barcode_reference_timestamp_millis_ == -1 ||
|
||||
frame_index_ % barcode_interval_ != 0) {
|
||||
return -1;
|
||||
}
|
||||
int64 now_millis = static_cast<int64>(rtc::Time()) * 1000;
|
||||
return static_cast<int32>(now_millis - barcode_reference_timestamp_millis_);
|
||||
int64_t now_millis = static_cast<int64_t>(rtc::Time()) * 1000;
|
||||
return static_cast<int32_t>(now_millis - barcode_reference_timestamp_millis_);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -70,7 +70,7 @@ class YuvFramesCapturer : public VideoCapturer {
|
||||
|
||||
protected:
|
||||
// Override virtual methods of parent class VideoCapturer.
|
||||
virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs);
|
||||
virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs);
|
||||
|
||||
// Read a frame and determine how long to wait for the next frame.
|
||||
void ReadFrame(bool first_frame);
|
||||
@ -83,12 +83,12 @@ class YuvFramesCapturer : public VideoCapturer {
|
||||
YuvFramesThread* frames_generator_thread;
|
||||
int width_;
|
||||
int height_;
|
||||
uint32 frame_data_size_;
|
||||
uint32 frame_index_;
|
||||
uint32_t frame_data_size_;
|
||||
uint32_t frame_index_;
|
||||
|
||||
int64 barcode_reference_timestamp_millis_;
|
||||
int32 barcode_interval_;
|
||||
int32 GetBarcodeValue();
|
||||
int64_t barcode_reference_timestamp_millis_;
|
||||
int32_t barcode_interval_;
|
||||
int32_t GetBarcodeValue();
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(YuvFramesCapturer);
|
||||
};
|
||||
|
||||
@ -88,7 +88,7 @@ std::string ListFlags(int flags) {
|
||||
|
||||
// Returns a comma-separated, human-readable list of the integers in 'array'.
|
||||
// All 'num_elems' of them.
|
||||
std::string ListArray(const uint16* array, int num_elems) {
|
||||
std::string ListArray(const uint16_t* array, int num_elems) {
|
||||
std::stringstream result;
|
||||
for (int i = 0; i < num_elems; ++i) {
|
||||
if (i) {
|
||||
@ -575,7 +575,7 @@ bool SctpDataMediaChannel::AddSendStream(const StreamParams& stream) {
|
||||
return AddStream(stream);
|
||||
}
|
||||
|
||||
bool SctpDataMediaChannel::RemoveSendStream(uint32 ssrc) {
|
||||
bool SctpDataMediaChannel::RemoveSendStream(uint32_t ssrc) {
|
||||
return ResetStream(ssrc);
|
||||
}
|
||||
|
||||
@ -586,7 +586,7 @@ bool SctpDataMediaChannel::AddRecvStream(const StreamParams& stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SctpDataMediaChannel::RemoveRecvStream(uint32 ssrc) {
|
||||
bool SctpDataMediaChannel::RemoveRecvStream(uint32_t ssrc) {
|
||||
// SCTP DataChannels are always bi-directional and calling RemoveSendStream
|
||||
// will disable both sending and receiving on the stream. So RemoveRecvStream
|
||||
// is a no-op.
|
||||
@ -727,7 +727,7 @@ bool SctpDataMediaChannel::AddStream(const StreamParams& stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint32 ssrc = stream.first_ssrc();
|
||||
const uint32_t ssrc = stream.first_ssrc();
|
||||
if (open_streams_.find(ssrc) != open_streams_.end()) {
|
||||
LOG(LS_WARNING) << debug_name_ << "->Add(Send|Recv)Stream(...): "
|
||||
<< "Not adding data stream '" << stream.id
|
||||
@ -747,7 +747,7 @@ bool SctpDataMediaChannel::AddStream(const StreamParams& stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SctpDataMediaChannel::ResetStream(uint32 ssrc) {
|
||||
bool SctpDataMediaChannel::ResetStream(uint32_t ssrc) {
|
||||
// We typically get this called twice for the same stream, once each for
|
||||
// Send and Recv.
|
||||
StreamSet::iterator found = open_streams_.find(ssrc);
|
||||
@ -997,10 +997,10 @@ bool SctpDataMediaChannel::SendQueuedStreamResets() {
|
||||
<< ListStreams(sent_reset_streams_) << "]";
|
||||
|
||||
const size_t num_streams = queued_reset_streams_.size();
|
||||
const size_t num_bytes = sizeof(struct sctp_reset_streams)
|
||||
+ (num_streams * sizeof(uint16));
|
||||
const size_t num_bytes =
|
||||
sizeof(struct sctp_reset_streams) + (num_streams * sizeof(uint16_t));
|
||||
|
||||
std::vector<uint8> reset_stream_buf(num_bytes, 0);
|
||||
std::vector<uint8_t> reset_stream_buf(num_bytes, 0);
|
||||
struct sctp_reset_streams* resetp = reinterpret_cast<sctp_reset_streams*>(
|
||||
&reset_stream_buf[0]);
|
||||
resetp->srs_assoc_id = SCTP_ALL_ASSOC;
|
||||
|
||||
@ -56,7 +56,7 @@ struct socket;
|
||||
namespace cricket {
|
||||
// The highest stream ID (Sid) that SCTP allows, and the number of streams we
|
||||
// tell SCTP we're going to use.
|
||||
const uint32 kMaxSctpSid = 1023;
|
||||
const uint32_t kMaxSctpSid = 1023;
|
||||
|
||||
// This is the default SCTP port to use. It is passed along the wire and the
|
||||
// connectee and connector must be using the same port. It is not related to the
|
||||
@ -134,7 +134,7 @@ class SctpDataMediaChannel : public DataMediaChannel,
|
||||
PPID_TEXT_LAST = 51
|
||||
};
|
||||
|
||||
typedef std::set<uint32> StreamSet;
|
||||
typedef std::set<uint32_t> StreamSet;
|
||||
|
||||
// Given a thread which will be used to post messages (received data) to this
|
||||
// SctpDataMediaChannel instance.
|
||||
@ -151,9 +151,9 @@ class SctpDataMediaChannel : public DataMediaChannel,
|
||||
virtual bool SetSendParameters(const DataSendParameters& params);
|
||||
virtual bool SetRecvParameters(const DataRecvParameters& params);
|
||||
virtual bool AddSendStream(const StreamParams& sp);
|
||||
virtual bool RemoveSendStream(uint32 ssrc);
|
||||
virtual bool RemoveSendStream(uint32_t ssrc);
|
||||
virtual bool AddRecvStream(const StreamParams& sp);
|
||||
virtual bool RemoveRecvStream(uint32 ssrc);
|
||||
virtual bool RemoveRecvStream(uint32_t ssrc);
|
||||
|
||||
// Called when Sctp gets data. The data may be a notification or data for
|
||||
// OnSctpInboundData. Called from the worker thread.
|
||||
@ -207,7 +207,7 @@ class SctpDataMediaChannel : public DataMediaChannel,
|
||||
// Adds a stream.
|
||||
bool AddStream(const StreamParams &sp);
|
||||
// Queues a stream for reset.
|
||||
bool ResetStream(uint32 ssrc);
|
||||
bool ResetStream(uint32_t ssrc);
|
||||
|
||||
// Called by OnMessage to send packet on the network.
|
||||
void OnPacketFromSctpToNetwork(rtc::Buffer* buffer);
|
||||
|
||||
@ -169,21 +169,19 @@ class SignalChannelClosedObserver : public sigslot::has_slots<> {
|
||||
channel->SignalStreamClosedRemotely.connect(
|
||||
this, &SignalChannelClosedObserver::OnStreamClosed);
|
||||
}
|
||||
void OnStreamClosed(uint32 stream) {
|
||||
streams_.push_back(stream);
|
||||
}
|
||||
void OnStreamClosed(uint32_t stream) { streams_.push_back(stream); }
|
||||
|
||||
int StreamCloseCount(uint32 stream) {
|
||||
int StreamCloseCount(uint32_t stream) {
|
||||
return std::count(streams_.begin(), streams_.end(), stream);
|
||||
}
|
||||
|
||||
bool WasStreamClosed(uint32 stream) {
|
||||
bool WasStreamClosed(uint32_t stream) {
|
||||
return std::find(streams_.begin(), streams_.end(), stream)
|
||||
!= streams_.end();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint32> streams_;
|
||||
std::vector<uint32_t> streams_;
|
||||
};
|
||||
|
||||
class SignalChannelClosedReopener : public sigslot::has_slots<> {
|
||||
@ -292,7 +290,8 @@ class SctpDataMediaChannelTest : public testing::Test,
|
||||
return channel;
|
||||
}
|
||||
|
||||
bool SendData(cricket::SctpDataMediaChannel* chan, uint32 ssrc,
|
||||
bool SendData(cricket::SctpDataMediaChannel* chan,
|
||||
uint32_t ssrc,
|
||||
const std::string& msg,
|
||||
cricket::SendDataResult* result) {
|
||||
cricket::SendDataParams params;
|
||||
@ -302,8 +301,9 @@ class SctpDataMediaChannelTest : public testing::Test,
|
||||
&msg[0], msg.length()), result);
|
||||
}
|
||||
|
||||
bool ReceivedData(const SctpFakeDataReceiver* recv, uint32 ssrc,
|
||||
const std::string& msg ) {
|
||||
bool ReceivedData(const SctpFakeDataReceiver* recv,
|
||||
uint32_t ssrc,
|
||||
const std::string& msg) {
|
||||
return (recv->received() &&
|
||||
recv->last_params().ssrc == ssrc &&
|
||||
recv->last_data() == msg);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user