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