OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/voice_engine/voe_video_sync_impl.h" | 11 #include "webrtc/voice_engine/voe_video_sync_impl.h" |
12 | 12 |
13 #include "webrtc/system_wrappers/include/trace.h" | 13 #include "webrtc/system_wrappers/include/trace.h" |
14 #include "webrtc/voice_engine/channel.h" | 14 #include "webrtc/voice_engine/channel.h" |
15 #include "webrtc/voice_engine/include/voe_errors.h" | 15 #include "webrtc/voice_engine/include/voe_errors.h" |
16 #include "webrtc/voice_engine/voice_engine_impl.h" | 16 #include "webrtc/voice_engine/voice_engine_impl.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 | 19 |
20 VoEVideoSync* VoEVideoSync::GetInterface(VoiceEngine* voiceEngine) { | 20 VoEVideoSync* VoEVideoSync::GetInterface(VoiceEngine* voiceEngine) { |
21 if (NULL == voiceEngine) { | 21 if (nullptr == voiceEngine) { |
22 return NULL; | 22 return nullptr; |
23 } | 23 } |
24 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); | 24 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
25 s->AddRef(); | 25 s->AddRef(); |
26 return s; | 26 return s; |
27 } | 27 } |
28 | 28 |
29 VoEVideoSyncImpl::VoEVideoSyncImpl(voe::SharedData* shared) : _shared(shared) { | 29 VoEVideoSyncImpl::VoEVideoSyncImpl(voe::SharedData* shared) : _shared(shared) { |
30 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), | 30 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
31 "VoEVideoSyncImpl::VoEVideoSyncImpl() - ctor"); | 31 "VoEVideoSyncImpl::VoEVideoSyncImpl() - ctor"); |
32 } | 32 } |
33 | 33 |
34 VoEVideoSyncImpl::~VoEVideoSyncImpl() { | 34 VoEVideoSyncImpl::~VoEVideoSyncImpl() { |
35 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), | 35 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), |
36 "VoEVideoSyncImpl::~VoEVideoSyncImpl() - dtor"); | 36 "VoEVideoSyncImpl::~VoEVideoSyncImpl() - dtor"); |
37 } | 37 } |
38 | 38 |
39 int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, | 39 int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, |
40 unsigned int& timestamp) { | 40 unsigned int& timestamp) { |
41 if (!_shared->statistics().Initialized()) { | 41 if (!_shared->statistics().Initialized()) { |
42 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 42 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
43 return -1; | 43 return -1; |
44 } | 44 } |
45 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 45 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
46 voe::Channel* channel_ptr = ch.channel(); | 46 voe::Channel* channel_ptr = ch.channel(); |
47 if (channel_ptr == NULL) { | 47 if (channel_ptr == nullptr) { |
48 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 48 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
49 "GetPlayoutTimestamp() failed to locate channel"); | 49 "GetPlayoutTimestamp() failed to locate channel"); |
50 return -1; | 50 return -1; |
51 } | 51 } |
52 return channel_ptr->GetPlayoutTimestamp(timestamp); | 52 return channel_ptr->GetPlayoutTimestamp(timestamp); |
53 } | 53 } |
54 | 54 |
55 int VoEVideoSyncImpl::SetInitTimestamp(int channel, unsigned int timestamp) { | 55 int VoEVideoSyncImpl::SetInitTimestamp(int channel, unsigned int timestamp) { |
56 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 56 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
57 "SetInitTimestamp(channel=%d, timestamp=%lu)", channel, | 57 "SetInitTimestamp(channel=%d, timestamp=%lu)", channel, |
58 timestamp); | 58 timestamp); |
59 | 59 |
60 if (!_shared->statistics().Initialized()) { | 60 if (!_shared->statistics().Initialized()) { |
61 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 61 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
62 return -1; | 62 return -1; |
63 } | 63 } |
64 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 64 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
65 voe::Channel* channelPtr = ch.channel(); | 65 voe::Channel* channelPtr = ch.channel(); |
66 if (channelPtr == NULL) { | 66 if (channelPtr == nullptr) { |
67 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 67 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
68 "SetInitTimestamp() failed to locate channel"); | 68 "SetInitTimestamp() failed to locate channel"); |
69 return -1; | 69 return -1; |
70 } | 70 } |
71 return channelPtr->SetInitTimestamp(timestamp); | 71 return channelPtr->SetInitTimestamp(timestamp); |
72 } | 72 } |
73 | 73 |
74 int VoEVideoSyncImpl::SetInitSequenceNumber(int channel, short sequenceNumber) { | 74 int VoEVideoSyncImpl::SetInitSequenceNumber(int channel, short sequenceNumber) { |
75 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 75 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
76 "SetInitSequenceNumber(channel=%d, sequenceNumber=%hd)", channel, | 76 "SetInitSequenceNumber(channel=%d, sequenceNumber=%hd)", channel, |
77 sequenceNumber); | 77 sequenceNumber); |
78 | 78 |
79 if (!_shared->statistics().Initialized()) { | 79 if (!_shared->statistics().Initialized()) { |
80 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 80 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
81 return -1; | 81 return -1; |
82 } | 82 } |
83 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 83 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
84 voe::Channel* channelPtr = ch.channel(); | 84 voe::Channel* channelPtr = ch.channel(); |
85 if (channelPtr == NULL) { | 85 if (channelPtr == nullptr) { |
86 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 86 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
87 "SetInitSequenceNumber() failed to locate channel"); | 87 "SetInitSequenceNumber() failed to locate channel"); |
88 return -1; | 88 return -1; |
89 } | 89 } |
90 return channelPtr->SetInitSequenceNumber(sequenceNumber); | 90 return channelPtr->SetInitSequenceNumber(sequenceNumber); |
91 } | 91 } |
92 | 92 |
93 int VoEVideoSyncImpl::SetMinimumPlayoutDelay(int channel, int delayMs) { | 93 int VoEVideoSyncImpl::SetMinimumPlayoutDelay(int channel, int delayMs) { |
94 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), | 94 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), |
95 "SetMinimumPlayoutDelay(channel=%d, delayMs=%d)", channel, | 95 "SetMinimumPlayoutDelay(channel=%d, delayMs=%d)", channel, |
96 delayMs); | 96 delayMs); |
97 | 97 |
98 if (!_shared->statistics().Initialized()) { | 98 if (!_shared->statistics().Initialized()) { |
99 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 99 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
100 return -1; | 100 return -1; |
101 } | 101 } |
102 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 102 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
103 voe::Channel* channelPtr = ch.channel(); | 103 voe::Channel* channelPtr = ch.channel(); |
104 if (channelPtr == NULL) { | 104 if (channelPtr == nullptr) { |
105 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 105 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
106 "SetMinimumPlayoutDelay() failed to locate channel"); | 106 "SetMinimumPlayoutDelay() failed to locate channel"); |
107 return -1; | 107 return -1; |
108 } | 108 } |
109 return channelPtr->SetMinimumPlayoutDelay(delayMs); | 109 return channelPtr->SetMinimumPlayoutDelay(delayMs); |
110 } | 110 } |
111 | 111 |
112 int VoEVideoSyncImpl::GetDelayEstimate(int channel, | 112 int VoEVideoSyncImpl::GetDelayEstimate(int channel, |
113 int* jitter_buffer_delay_ms, | 113 int* jitter_buffer_delay_ms, |
114 int* playout_buffer_delay_ms) { | 114 int* playout_buffer_delay_ms) { |
115 if (!_shared->statistics().Initialized()) { | 115 if (!_shared->statistics().Initialized()) { |
116 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 116 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
117 return -1; | 117 return -1; |
118 } | 118 } |
119 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 119 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
120 voe::Channel* channelPtr = ch.channel(); | 120 voe::Channel* channelPtr = ch.channel(); |
121 if (channelPtr == NULL) { | 121 if (channelPtr == nullptr) { |
122 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 122 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
123 "GetDelayEstimate() failed to locate channel"); | 123 "GetDelayEstimate() failed to locate channel"); |
124 return -1; | 124 return -1; |
125 } | 125 } |
126 if (!channelPtr->GetDelayEstimate(jitter_buffer_delay_ms, | 126 if (!channelPtr->GetDelayEstimate(jitter_buffer_delay_ms, |
127 playout_buffer_delay_ms)) { | 127 playout_buffer_delay_ms)) { |
128 return -1; | 128 return -1; |
129 } | 129 } |
130 return 0; | 130 return 0; |
131 } | 131 } |
(...skipping 16 matching lines...) Expand all Loading... |
148 | 148 |
149 int VoEVideoSyncImpl::GetRtpRtcp(int channel, | 149 int VoEVideoSyncImpl::GetRtpRtcp(int channel, |
150 RtpRtcp** rtpRtcpModule, | 150 RtpRtcp** rtpRtcpModule, |
151 RtpReceiver** rtp_receiver) { | 151 RtpReceiver** rtp_receiver) { |
152 if (!_shared->statistics().Initialized()) { | 152 if (!_shared->statistics().Initialized()) { |
153 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 153 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
154 return -1; | 154 return -1; |
155 } | 155 } |
156 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 156 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
157 voe::Channel* channelPtr = ch.channel(); | 157 voe::Channel* channelPtr = ch.channel(); |
158 if (channelPtr == NULL) { | 158 if (channelPtr == nullptr) { |
159 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 159 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
160 "GetPlayoutTimestamp() failed to locate channel"); | 160 "GetPlayoutTimestamp() failed to locate channel"); |
161 return -1; | 161 return -1; |
162 } | 162 } |
163 return channelPtr->GetRtpRtcp(rtpRtcpModule, rtp_receiver); | 163 return channelPtr->GetRtpRtcp(rtpRtcpModule, rtp_receiver); |
164 } | 164 } |
165 | 165 |
166 int VoEVideoSyncImpl::GetLeastRequiredDelayMs(int channel) const { | 166 int VoEVideoSyncImpl::GetLeastRequiredDelayMs(int channel) const { |
167 if (!_shared->statistics().Initialized()) { | 167 if (!_shared->statistics().Initialized()) { |
168 _shared->SetLastError(VE_NOT_INITED, kTraceError); | 168 _shared->SetLastError(VE_NOT_INITED, kTraceError); |
169 return -1; | 169 return -1; |
170 } | 170 } |
171 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); | 171 voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); |
172 voe::Channel* channel_ptr = ch.channel(); | 172 voe::Channel* channel_ptr = ch.channel(); |
173 if (channel_ptr == NULL) { | 173 if (channel_ptr == nullptr) { |
174 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 174 _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
175 "GetLeastRequiredDelayMs() failed to locate channel"); | 175 "GetLeastRequiredDelayMs() failed to locate channel"); |
176 return -1; | 176 return -1; |
177 } | 177 } |
178 return channel_ptr->LeastRequiredDelayMs(); | 178 return channel_ptr->LeastRequiredDelayMs(); |
179 } | 179 } |
180 | 180 |
181 } // namespace webrtc | 181 } // namespace webrtc |
OLD | NEW |