Fixes issues related to intra requests.
TEST=video_coding_unittests BUG= Review URL: https://webrtc-codereview.appspot.com/936005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2991 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
d7ee10fe0f
commit
cf21686cd5
@ -24,7 +24,7 @@ _codecType(kVideoCodecUnknown),
|
|||||||
_VCMencodedFrameCallback(NULL),
|
_VCMencodedFrameCallback(NULL),
|
||||||
_bitRate(0),
|
_bitRate(0),
|
||||||
_frameRate(0),
|
_frameRate(0),
|
||||||
_internalSource(false)
|
_internalSource(internalSource)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +59,10 @@ VCMGenericEncoder::InitEncode(const VideoCodec* settings,
|
|||||||
WebRtc_Word32
|
WebRtc_Word32
|
||||||
VCMGenericEncoder::Encode(const I420VideoFrame& inputFrame,
|
VCMGenericEncoder::Encode(const I420VideoFrame& inputFrame,
|
||||||
const CodecSpecificInfo* codecSpecificInfo,
|
const CodecSpecificInfo* codecSpecificInfo,
|
||||||
const std::vector<FrameType>* frameTypes) {
|
const std::vector<FrameType>& frameTypes) {
|
||||||
std::vector<VideoFrameType> video_frame_types(frameTypes->size(),
|
std::vector<VideoFrameType> video_frame_types(frameTypes.size(),
|
||||||
kDeltaFrame);
|
kDeltaFrame);
|
||||||
if (frameTypes) {
|
VCMEncodedFrame::ConvertFrameTypes(frameTypes, &video_frame_types);
|
||||||
VCMEncodedFrame::ConvertFrameTypes(*frameTypes, &video_frame_types);
|
|
||||||
}
|
|
||||||
return _encoder.Encode(inputFrame, codecSpecificInfo, &video_frame_types);
|
return _encoder.Encode(inputFrame, codecSpecificInfo, &video_frame_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,15 +113,11 @@ VCMGenericEncoder::SetPeriodicKeyFrames(bool enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VCMGenericEncoder::RequestFrame(
|
WebRtc_Word32 VCMGenericEncoder::RequestFrame(
|
||||||
const std::vector<FrameType>* frame_types) {
|
const std::vector<FrameType>& frame_types) {
|
||||||
if (!frame_types) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
I420VideoFrame image;
|
I420VideoFrame image;
|
||||||
std::vector<VideoFrameType> video_frame_types(kVideoFrameDelta);
|
std::vector<VideoFrameType> video_frame_types(frame_types.size(),
|
||||||
if (frame_types) {
|
kDeltaFrame);
|
||||||
VCMEncodedFrame::ConvertFrameTypes(*frame_types, &video_frame_types);
|
VCMEncodedFrame::ConvertFrameTypes(frame_types, &video_frame_types);
|
||||||
}
|
|
||||||
return _encoder.Encode(image, NULL, &video_frame_types);
|
return _encoder.Encode(image, NULL, &video_frame_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
WebRtc_Word32 Encode(const I420VideoFrame& inputFrame,
|
WebRtc_Word32 Encode(const I420VideoFrame& inputFrame,
|
||||||
const CodecSpecificInfo* codecSpecificInfo,
|
const CodecSpecificInfo* codecSpecificInfo,
|
||||||
const std::vector<FrameType>* frameTypes);
|
const std::vector<FrameType>& frameTypes);
|
||||||
/**
|
/**
|
||||||
* Set new target bit rate and frame rate
|
* Set new target bit rate and frame rate
|
||||||
* Return Value: new bit rate if OK, otherwise <0s
|
* Return Value: new bit rate if OK, otherwise <0s
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
WebRtc_Word32 SetPeriodicKeyFrames(bool enable);
|
WebRtc_Word32 SetPeriodicKeyFrames(bool enable);
|
||||||
|
|
||||||
WebRtc_Word32 RequestFrame(const std::vector<FrameType>* frame_types);
|
WebRtc_Word32 RequestFrame(const std::vector<FrameType>& frame_types);
|
||||||
|
|
||||||
bool InternalSource() const;
|
bool InternalSource() const;
|
||||||
|
|
||||||
|
@ -683,7 +683,7 @@ VideoCodingModuleImpl::AddVideoFrame(const I420VideoFrame& videoFrame,
|
|||||||
_mediaOpt.updateContentData(contentMetrics);
|
_mediaOpt.updateContentData(contentMetrics);
|
||||||
WebRtc_Word32 ret = _encoder->Encode(videoFrame,
|
WebRtc_Word32 ret = _encoder->Encode(videoFrame,
|
||||||
codecSpecificInfo,
|
codecSpecificInfo,
|
||||||
&_nextFrameTypes);
|
_nextFrameTypes);
|
||||||
if (_encoderInputFile != NULL)
|
if (_encoderInputFile != NULL)
|
||||||
{
|
{
|
||||||
if (PrintI420VideoFrame(videoFrame, _encoderInputFile) < 0)
|
if (PrintI420VideoFrame(videoFrame, _encoderInputFile) < 0)
|
||||||
@ -707,13 +707,16 @@ VideoCodingModuleImpl::AddVideoFrame(const I420VideoFrame& videoFrame,
|
|||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 VideoCodingModuleImpl::IntraFrameRequest(int stream_index) {
|
WebRtc_Word32 VideoCodingModuleImpl::IntraFrameRequest(int stream_index) {
|
||||||
assert(stream_index >= 0);
|
|
||||||
CriticalSectionScoped cs(_sendCritSect);
|
CriticalSectionScoped cs(_sendCritSect);
|
||||||
|
if (stream_index < 0 ||
|
||||||
|
static_cast<unsigned int>(stream_index) >= _nextFrameTypes.size()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
_nextFrameTypes[stream_index] = kVideoFrameKey;
|
_nextFrameTypes[stream_index] = kVideoFrameKey;
|
||||||
if (_encoder != NULL && _encoder->InternalSource()) {
|
if (_encoder != NULL && _encoder->InternalSource()) {
|
||||||
// Try to request the frame if we have an external encoder with
|
// Try to request the frame if we have an external encoder with
|
||||||
// internal source since AddVideoFrame never will be called.
|
// internal source since AddVideoFrame never will be called.
|
||||||
if (_encoder->RequestFrame(&_nextFrameTypes) ==
|
if (_encoder->RequestFrame(_nextFrameTypes) ==
|
||||||
WEBRTC_VIDEO_CODEC_OK) {
|
WEBRTC_VIDEO_CODEC_OK) {
|
||||||
_nextFrameTypes[stream_index] = kVideoFrameDelta;
|
_nextFrameTypes[stream_index] = kVideoFrameDelta;
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,32 @@ TEST_F(TestVideoCodingModule, TestIntraRequests) {
|
|||||||
EXPECT_EQ(0, vcm_->AddVideoFrame(input_frame_, NULL, NULL));
|
EXPECT_EQ(0, vcm_->AddVideoFrame(input_frame_, NULL, NULL));
|
||||||
ExpectIntraRequest(-1);
|
ExpectIntraRequest(-1);
|
||||||
EXPECT_EQ(0, vcm_->AddVideoFrame(input_frame_, NULL, NULL));
|
EXPECT_EQ(0, vcm_->AddVideoFrame(input_frame_, NULL, NULL));
|
||||||
|
|
||||||
|
EXPECT_EQ(-1, vcm_->IntraFrameRequest(3));
|
||||||
|
ExpectIntraRequest(-1);
|
||||||
|
EXPECT_EQ(0, vcm_->AddVideoFrame(input_frame_, NULL, NULL));
|
||||||
|
|
||||||
|
EXPECT_EQ(-1, vcm_->IntraFrameRequest(-1));
|
||||||
|
ExpectIntraRequest(-1);
|
||||||
|
EXPECT_EQ(0, vcm_->AddVideoFrame(input_frame_, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(TestVideoCodingModule, TestIntraRequestsInternalCapture) {
|
||||||
|
// De-register current external encoder.
|
||||||
|
EXPECT_EQ(0, vcm_->RegisterExternalEncoder(NULL, kUnusedPayloadType, false));
|
||||||
|
// Register encoder with internal capture.
|
||||||
|
EXPECT_EQ(0, vcm_->RegisterExternalEncoder(&encoder_, kUnusedPayloadType,
|
||||||
|
true));
|
||||||
|
EXPECT_EQ(0, vcm_->RegisterSendCodec(&settings_, 1, 1200));
|
||||||
|
ExpectIntraRequest(0);
|
||||||
|
EXPECT_EQ(0, vcm_->IntraFrameRequest(0));
|
||||||
|
ExpectIntraRequest(1);
|
||||||
|
EXPECT_EQ(0, vcm_->IntraFrameRequest(1));
|
||||||
|
ExpectIntraRequest(2);
|
||||||
|
EXPECT_EQ(0, vcm_->IntraFrameRequest(2));
|
||||||
|
// No requests expected since these indices are out of bounds.
|
||||||
|
EXPECT_EQ(-1, vcm_->IntraFrameRequest(3));
|
||||||
|
EXPECT_EQ(-1, vcm_->IntraFrameRequest(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user