OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #endif | 56 #endif |
57 } | 57 } |
58 | 58 |
59 VideoReceiver::~VideoReceiver() { | 59 VideoReceiver::~VideoReceiver() { |
60 delete _receiveCritSect; | 60 delete _receiveCritSect; |
61 #ifdef DEBUG_DECODER_BIT_STREAM | 61 #ifdef DEBUG_DECODER_BIT_STREAM |
62 fclose(_bitStreamBeforeDecoder); | 62 fclose(_bitStreamBeforeDecoder); |
63 #endif | 63 #endif |
64 } | 64 } |
65 | 65 |
66 int32_t VideoReceiver::Process() { | 66 void VideoReceiver::Process() { |
67 int32_t returnValue = VCM_OK; | |
68 | |
69 // Receive-side statistics | 67 // Receive-side statistics |
70 if (_receiveStatsTimer.TimeUntilProcess() == 0) { | 68 if (_receiveStatsTimer.TimeUntilProcess() == 0) { |
71 _receiveStatsTimer.Processed(); | 69 _receiveStatsTimer.Processed(); |
72 CriticalSectionScoped cs(process_crit_sect_.get()); | 70 CriticalSectionScoped cs(process_crit_sect_.get()); |
73 if (_receiveStatsCallback != NULL) { | 71 if (_receiveStatsCallback != NULL) { |
74 uint32_t bitRate; | 72 uint32_t bitRate; |
75 uint32_t frameRate; | 73 uint32_t frameRate; |
76 _receiver.ReceiveStatistics(&bitRate, &frameRate); | 74 _receiver.ReceiveStatistics(&bitRate, &frameRate); |
77 _receiveStatsCallback->OnReceiveRatesUpdated(bitRate, frameRate); | 75 _receiveStatsCallback->OnReceiveRatesUpdated(bitRate, frameRate); |
78 } | 76 } |
(...skipping 22 matching lines...) Expand all Loading... |
101 } | 99 } |
102 | 100 |
103 // Key frame requests | 101 // Key frame requests |
104 if (_keyRequestTimer.TimeUntilProcess() == 0) { | 102 if (_keyRequestTimer.TimeUntilProcess() == 0) { |
105 _keyRequestTimer.Processed(); | 103 _keyRequestTimer.Processed(); |
106 bool request_key_frame = false; | 104 bool request_key_frame = false; |
107 { | 105 { |
108 CriticalSectionScoped cs(process_crit_sect_.get()); | 106 CriticalSectionScoped cs(process_crit_sect_.get()); |
109 request_key_frame = _scheduleKeyRequest && _frameTypeCallback != NULL; | 107 request_key_frame = _scheduleKeyRequest && _frameTypeCallback != NULL; |
110 } | 108 } |
111 if (request_key_frame) { | 109 if (request_key_frame) |
112 const int32_t ret = RequestKeyFrame(); | 110 RequestKeyFrame(); |
113 if (ret != VCM_OK && returnValue == VCM_OK) { | |
114 returnValue = ret; | |
115 } | |
116 } | |
117 } | 111 } |
118 | 112 |
119 // Packet retransmission requests | 113 // Packet retransmission requests |
120 // TODO(holmer): Add API for changing Process interval and make sure it's | 114 // TODO(holmer): Add API for changing Process interval and make sure it's |
121 // disabled when NACK is off. | 115 // disabled when NACK is off. |
122 if (_retransmissionTimer.TimeUntilProcess() == 0) { | 116 if (_retransmissionTimer.TimeUntilProcess() == 0) { |
123 _retransmissionTimer.Processed(); | 117 _retransmissionTimer.Processed(); |
124 bool callback_registered = false; | 118 bool callback_registered = false; |
125 uint16_t length; | 119 uint16_t length; |
126 { | 120 { |
127 CriticalSectionScoped cs(process_crit_sect_.get()); | 121 CriticalSectionScoped cs(process_crit_sect_.get()); |
128 length = max_nack_list_size_; | 122 length = max_nack_list_size_; |
129 callback_registered = _packetRequestCallback != NULL; | 123 callback_registered = _packetRequestCallback != NULL; |
130 } | 124 } |
131 if (callback_registered && length > 0) { | 125 if (callback_registered && length > 0) { |
132 // Collect sequence numbers from the default receiver. | 126 // Collect sequence numbers from the default receiver. |
133 bool request_key_frame = false; | 127 bool request_key_frame = false; |
134 std::vector<uint16_t> nackList = _receiver.NackList(&request_key_frame); | 128 std::vector<uint16_t> nackList = _receiver.NackList(&request_key_frame); |
135 int32_t ret = VCM_OK; | 129 int32_t ret = VCM_OK; |
136 if (request_key_frame) { | 130 if (request_key_frame) { |
137 ret = RequestKeyFrame(); | 131 ret = RequestKeyFrame(); |
138 if (ret != VCM_OK && returnValue == VCM_OK) { | |
139 returnValue = ret; | |
140 } | |
141 } | 132 } |
142 if (ret == VCM_OK && !nackList.empty()) { | 133 if (ret == VCM_OK && !nackList.empty()) { |
143 CriticalSectionScoped cs(process_crit_sect_.get()); | 134 CriticalSectionScoped cs(process_crit_sect_.get()); |
144 if (_packetRequestCallback != NULL) { | 135 if (_packetRequestCallback != NULL) { |
145 _packetRequestCallback->ResendPackets(&nackList[0], nackList.size()); | 136 _packetRequestCallback->ResendPackets(&nackList[0], nackList.size()); |
146 } | 137 } |
147 } | 138 } |
148 } | 139 } |
149 } | 140 } |
150 | |
151 return returnValue; | |
152 } | 141 } |
153 | 142 |
154 int64_t VideoReceiver::TimeUntilNextProcess() { | 143 int64_t VideoReceiver::TimeUntilNextProcess() { |
155 int64_t timeUntilNextProcess = _receiveStatsTimer.TimeUntilProcess(); | 144 int64_t timeUntilNextProcess = _receiveStatsTimer.TimeUntilProcess(); |
156 if (_receiver.NackMode() != kNoNack) { | 145 if (_receiver.NackMode() != kNoNack) { |
157 // We need a Process call more often if we are relying on | 146 // We need a Process call more often if we are relying on |
158 // retransmissions | 147 // retransmissions |
159 timeUntilNextProcess = | 148 timeUntilNextProcess = |
160 VCM_MIN(timeUntilNextProcess, _retransmissionTimer.TimeUntilProcess()); | 149 VCM_MIN(timeUntilNextProcess, _retransmissionTimer.TimeUntilProcess()); |
161 } | 150 } |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 } | 527 } |
539 | 528 |
540 void VideoReceiver::RegisterPreDecodeImageCallback( | 529 void VideoReceiver::RegisterPreDecodeImageCallback( |
541 EncodedImageCallback* observer) { | 530 EncodedImageCallback* observer) { |
542 CriticalSectionScoped cs(_receiveCritSect); | 531 CriticalSectionScoped cs(_receiveCritSect); |
543 pre_decode_image_callback_ = observer; | 532 pre_decode_image_callback_ = observer; |
544 } | 533 } |
545 | 534 |
546 } // namespace vcm | 535 } // namespace vcm |
547 } // namespace webrtc | 536 } // namespace webrtc |
OLD | NEW |