Adding DeliverCaptureEncodedFrame

Review URL: https://webrtc-codereview.appspot.com/860012

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2909 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2012-10-11 15:03:53 +00:00
parent 09a1ef53a5
commit 80f14d20c4
2 changed files with 48 additions and 6 deletions

View File

@ -209,8 +209,44 @@ WebRtc_Word32 VideoCaptureImpl::CaptureDelay()
WebRtc_Word32 VideoCaptureImpl::DeliverCapturedFrame(VideoFrame& captureFrame,
WebRtc_Word64 capture_time, VideoCodecType codec_type) {
UpdateFrameCount();// frame count used for local frame rate callback.
_startImageFrameIntervall = 0; // prevent the start image to be displayed.
UpdateFrameCount(); // frame count used for local frame rate callback.
_startImageFrameIntervall = 0; // prevent the start image to be displayed.
const bool callOnCaptureDelayChanged = _setCaptureDelay != _captureDelay;
// Capture delay changed
if (_setCaptureDelay != _captureDelay) {
_setCaptureDelay = _captureDelay;
}
// Set the capture time
if (capture_time != 0) {
captureFrame.SetRenderTime(capture_time);
}
else {
captureFrame.SetRenderTime(TickTime::MillisecondTimestamp());
}
if (captureFrame.RenderTimeMs() == last_capture_time_) {
// We don't allow the same capture time for two frames, drop this one.
return -1;
}
last_capture_time_ = captureFrame.RenderTimeMs();
if (_dataCallBack) {
if (callOnCaptureDelayChanged) {
_dataCallBack->OnCaptureDelayChanged(_id, _captureDelay);
}
_dataCallBack->OnIncomingCapturedFrame(_id, captureFrame, codec_type);
}
return 0;
}
WebRtc_Word32 VideoCaptureImpl::DeliverEncodedCapturedFrame(
VideoFrame& captureFrame, WebRtc_Word64 capture_time,
VideoCodecType codec_type) {
UpdateFrameCount(); // frame count used for local frame rate callback.
_startImageFrameIntervall = 0; // prevent the start image to be displayed.
const bool callOnCaptureDelayChanged = _setCaptureDelay != _captureDelay;
// Capture delay changed
@ -306,18 +342,20 @@ WebRtc_Word32 VideoCaptureImpl::IncomingFrame(
return -1;
}
_captureFrame.SetLength(requiredLength);
DeliverCapturedFrame(_captureFrame, captureTime, frameInfo.codecType);
}
else // Encoded format
{
if (_captureFrame.CopyFrame(videoFrameLength, videoFrame) != 0)
if (_capture_encoded_frame.CopyFrame(videoFrameLength, videoFrame) != 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
"Failed to copy captured frame of length %d", (int) videoFrameLength);
"Failed to copy captured frame of length %d",
static_cast<int>(videoFrameLength));
}
DeliverEncodedCapturedFrame(_capture_encoded_frame, captureTime,
frameInfo.codecType);
}
DeliverCapturedFrame(_captureFrame, captureTime, frameInfo.codecType);
const WebRtc_UWord32 processTime =
(WebRtc_UWord32)(TickTime::Now() - startProcessTime).Milliseconds();

View File

@ -104,6 +104,9 @@ protected:
WebRtc_Word32 DeliverCapturedFrame(
VideoFrame& captureFrame,
WebRtc_Word64 capture_time, VideoCodecType codec_type);
WebRtc_Word32 DeliverEncodedCapturedFrame(
VideoFrame& captureFrame,
WebRtc_Word64 capture_time, VideoCodecType codec_type);
WebRtc_Word32 _id; // Module ID
char* _deviceUniqueId; // current Device unique name;
@ -134,6 +137,7 @@ private:
VideoRotationMode _rotateFrame; //Set if the frame should be rotated by the capture module.
VideoFrame _captureFrame;
VideoFrame _capture_encoded_frame;
// Used to make sure incoming timestamp is increasing for every frame.
WebRtc_Word64 last_capture_time_;