Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Unified Diff: webrtc/modules/video_coding/generic_decoder.cc

Issue 2744013002: Updates to VCMDecodedFrameCallback, VideoReceiver and a few related classes/tests. (Closed)
Patch Set: Address comments and replace a few assert calls with RTC_DCHECK Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/generic_decoder.cc
diff --git a/webrtc/modules/video_coding/generic_decoder.cc b/webrtc/modules/video_coding/generic_decoder.cc
index 34500c69e2a39f9b69b0e2488318ce75ee0e370f..2121ab63067acdafe71e7f1cb7ceaf90c3b1196d 100644
--- a/webrtc/modules/video_coding/generic_decoder.cc
+++ b/webrtc/modules/video_coding/generic_decoder.cc
@@ -20,25 +20,26 @@ namespace webrtc {
VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming* timing,
Clock* clock)
- : _critSect(CriticalSectionWrapper::CreateCriticalSection()),
- _clock(clock),
- _receiveCallback(NULL),
+ : _clock(clock),
_timing(timing),
_timestampMap(kDecoderFrameMemoryLength),
_lastReceivedPictureID(0) {}
VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {
- delete _critSect;
}
void VCMDecodedFrameCallback::SetUserReceiveCallback(
VCMReceiveCallback* receiveCallback) {
- CriticalSectionScoped cs(_critSect);
+ RTC_DCHECK(construction_thread_.CalledOnValidThread());
+ RTC_DCHECK((!_receiveCallback && receiveCallback) ||
+ (_receiveCallback && !receiveCallback));
_receiveCallback = receiveCallback;
}
VCMReceiveCallback* VCMDecodedFrameCallback::UserReceiveCallback() {
- CriticalSectionScoped cs(_critSect);
+ // Called on the decode thread via VCMCodecDataBase::GetDecoder.
+ // The callback must always have been set before this happens.
+ RTC_DCHECK(_receiveCallback);
return _receiveCallback;
}
@@ -58,16 +59,15 @@ int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
rtc::Optional<int32_t> decode_time_ms,
rtc::Optional<uint8_t> qp) {
+ RTC_DCHECK(_receiveCallback) << "Callback must not be null at this point";
TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
"timestamp", decodedImage.timestamp());
// TODO(holmer): We should improve this so that we can handle multiple
// callbacks from one call to Decode().
VCMFrameInformation* frameInfo;
- VCMReceiveCallback* callback;
{
- CriticalSectionScoped cs(_critSect);
+ rtc::CritScope cs(&lock_);
frameInfo = _timestampMap.Pop(decodedImage.timestamp());
- callback = _receiveCallback;
}
if (frameInfo == NULL) {
@@ -87,22 +87,12 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
decodedImage.set_timestamp_us(
frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec);
decodedImage.set_rotation(frameInfo->rotation);
- // TODO(sakal): Investigate why callback is NULL sometimes and replace if
- // statement with a DCHECK.
- if (callback) {
- callback->FrameToRender(decodedImage, qp);
- } else {
- LOG(LS_WARNING) << "No callback, dropping frame.";
- }
+ _receiveCallback->FrameToRender(decodedImage, qp);
}
int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
const uint64_t pictureId) {
- CriticalSectionScoped cs(_critSect);
- if (_receiveCallback != NULL) {
- return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
- }
- return -1;
+ return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
}
int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame(
@@ -117,19 +107,17 @@ uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const {
void VCMDecodedFrameCallback::OnDecoderImplementationName(
const char* implementation_name) {
- CriticalSectionScoped cs(_critSect);
- if (_receiveCallback)
- _receiveCallback->OnDecoderImplementationName(implementation_name);
+ _receiveCallback->OnDecoderImplementationName(implementation_name);
}
void VCMDecodedFrameCallback::Map(uint32_t timestamp,
VCMFrameInformation* frameInfo) {
- CriticalSectionScoped cs(_critSect);
+ rtc::CritScope cs(&lock_);
_timestampMap.Add(timestamp, frameInfo);
}
int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) {
- CriticalSectionScoped cs(_critSect);
+ rtc::CritScope cs(&lock_);
if (_timestampMap.Pop(timestamp) == NULL) {
return VCM_GENERAL_ERROR;
}

Powered by Google App Engine
This is Rietveld 408576698