(Auto)update libjingle 72682155-> 72785180
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6841 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
aaecefe72a
commit
4f0d401fae
@ -489,8 +489,6 @@
|
||||
'media/base/mediacommon.h',
|
||||
'media/base/mediaengine.cc',
|
||||
'media/base/mediaengine.h',
|
||||
'media/base/mutedvideocapturer.cc',
|
||||
'media/base/mutedvideocapturer.h',
|
||||
'media/base/rtpdataengine.cc',
|
||||
'media/base/rtpdataengine.h',
|
||||
'media/base/rtpdump.cc',
|
||||
@ -508,6 +506,7 @@
|
||||
'media/base/videocommon.h',
|
||||
'media/base/videoframe.cc',
|
||||
'media/base/videoframe.h',
|
||||
'media/base/videoframefactory.h',
|
||||
'media/base/videoprocessor.h',
|
||||
'media/base/videorenderer.h',
|
||||
'media/base/voiceprocessor.h',
|
||||
@ -543,6 +542,8 @@
|
||||
'media/webrtc/webrtcvideoengine2.h',
|
||||
'media/webrtc/webrtcvideoframe.cc',
|
||||
'media/webrtc/webrtcvideoframe.h',
|
||||
'media/webrtc/webrtcvideoframefactory.cc',
|
||||
'media/webrtc/webrtcvideoframefactory.h',
|
||||
'media/webrtc/webrtcvie.h',
|
||||
'media/webrtc/webrtcvoe.h',
|
||||
'media/webrtc/webrtcvoiceengine.cc',
|
||||
|
@ -148,6 +148,7 @@
|
||||
'media/base/streamparams_unittest.cc',
|
||||
'media/base/testutils.cc',
|
||||
'media/base/testutils.h',
|
||||
'media/base/videoadapter_unittest.cc',
|
||||
'media/base/videocapturer_unittest.cc',
|
||||
'media/base/videocommon_unittest.cc',
|
||||
'media/base/videoengine_unittest.h',
|
||||
|
@ -36,6 +36,9 @@
|
||||
#include "talk/media/base/videocapturer.h"
|
||||
#include "talk/media/base/videocommon.h"
|
||||
#include "talk/media/base/videoframe.h"
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
#include "talk/media/webrtc/webrtcvideoframefactory.h"
|
||||
#endif
|
||||
|
||||
namespace cricket {
|
||||
|
||||
@ -47,6 +50,9 @@ class FakeVideoCapturer : public cricket::VideoCapturer {
|
||||
initial_unix_timestamp_(time(NULL) * rtc::kNumNanosecsPerSec),
|
||||
next_timestamp_(rtc::kNumNanosecsPerMillisec),
|
||||
is_screencast_(false) {
|
||||
#ifdef HAVE_WEBRTC_VIDEO
|
||||
set_frame_factory(new cricket::WebRtcVideoFrameFactory());
|
||||
#endif
|
||||
// Default supported formats. Use ResetSupportedFormats to over write.
|
||||
std::vector<cricket::VideoFormat> formats;
|
||||
formats.push_back(cricket::VideoFormat(1280, 720,
|
||||
|
@ -1,135 +1,2 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "talk/media/base/mutedvideocapturer.h"
|
||||
#include "talk/media/base/videoframe.h"
|
||||
|
||||
#if defined(HAVE_WEBRTC_VIDEO)
|
||||
#include "talk/media/webrtc/webrtcvideoframe.h"
|
||||
#endif // HAVE_WEBRTC_VIDEO
|
||||
|
||||
|
||||
namespace cricket {
|
||||
|
||||
const char MutedVideoCapturer::kCapturerId[] = "muted_camera";
|
||||
|
||||
class MutedFramesGenerator : public rtc::MessageHandler {
|
||||
public:
|
||||
explicit MutedFramesGenerator(const VideoFormat& format);
|
||||
virtual ~MutedFramesGenerator();
|
||||
|
||||
// Called every |interval| ms. From |format|.interval given in the
|
||||
// constructor.
|
||||
sigslot::signal1<VideoFrame*> SignalFrame;
|
||||
|
||||
protected:
|
||||
virtual void OnMessage(rtc::Message* message);
|
||||
|
||||
private:
|
||||
rtc::Thread capture_thread_;
|
||||
rtc::scoped_ptr<VideoFrame> muted_frame_;
|
||||
const VideoFormat format_;
|
||||
const int interval_;
|
||||
uint32 create_time_;
|
||||
};
|
||||
|
||||
MutedFramesGenerator::MutedFramesGenerator(const VideoFormat& format)
|
||||
: format_(format),
|
||||
interval_(static_cast<int>(format.interval /
|
||||
rtc::kNumNanosecsPerMillisec)),
|
||||
create_time_(rtc::Time()) {
|
||||
capture_thread_.Start();
|
||||
capture_thread_.PostDelayed(interval_, this);
|
||||
}
|
||||
|
||||
MutedFramesGenerator::~MutedFramesGenerator() { capture_thread_.Clear(this); }
|
||||
|
||||
void MutedFramesGenerator::OnMessage(rtc::Message* message) {
|
||||
// Queue a new frame as soon as possible to minimize drift.
|
||||
capture_thread_.PostDelayed(interval_, this);
|
||||
if (!muted_frame_) {
|
||||
#if defined(HAVE_WEBRTC_VIDEO)
|
||||
#define VIDEO_FRAME_NAME WebRtcVideoFrame
|
||||
#endif
|
||||
#if defined(VIDEO_FRAME_NAME)
|
||||
muted_frame_.reset(new VIDEO_FRAME_NAME());
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
uint32 current_timestamp = rtc::Time();
|
||||
// Delta between create time and current time will be correct even if there is
|
||||
// a wraparound since they are unsigned integers.
|
||||
uint32 elapsed_time = current_timestamp - create_time_;
|
||||
if (!muted_frame_->InitToBlack(format_.width, format_.height, 1, 1,
|
||||
elapsed_time, current_timestamp)) {
|
||||
LOG(LS_ERROR) << "Failed to create a black frame.";
|
||||
}
|
||||
SignalFrame(muted_frame_.get());
|
||||
}
|
||||
|
||||
MutedVideoCapturer::MutedVideoCapturer() { SetId(kCapturerId); }
|
||||
|
||||
MutedVideoCapturer::~MutedVideoCapturer() { Stop(); }
|
||||
|
||||
bool MutedVideoCapturer::GetBestCaptureFormat(const VideoFormat& desired,
|
||||
VideoFormat* best_format) {
|
||||
*best_format = desired;
|
||||
return true;
|
||||
}
|
||||
|
||||
CaptureState MutedVideoCapturer::Start(const VideoFormat& capture_format) {
|
||||
if (frame_generator_.get()) {
|
||||
return CS_RUNNING;
|
||||
}
|
||||
frame_generator_.reset(new MutedFramesGenerator(capture_format));
|
||||
frame_generator_->SignalFrame
|
||||
.connect(this, &MutedVideoCapturer::OnMutedFrame);
|
||||
SetCaptureFormat(&capture_format);
|
||||
return CS_RUNNING;
|
||||
}
|
||||
|
||||
void MutedVideoCapturer::Stop() {
|
||||
frame_generator_.reset();
|
||||
SetCaptureFormat(NULL);
|
||||
}
|
||||
|
||||
bool MutedVideoCapturer::IsRunning() { return frame_generator_.get() != NULL; }
|
||||
|
||||
bool MutedVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
|
||||
fourccs->clear();
|
||||
fourccs->push_back(cricket::FOURCC_I420);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MutedVideoCapturer::OnMutedFrame(VideoFrame* muted_frame) {
|
||||
SignalVideoFrame(this, muted_frame);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
// TODO(pthatcher): Delete this file. Pulse won't work without it for
|
||||
// some reason.
|
||||
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/media/base/mutedvideocapturer.h"
|
||||
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "talk/media/base/videoframe.h"
|
||||
|
||||
class MutedVideoCapturerTest : public sigslot::has_slots<>,
|
||||
public testing::Test {
|
||||
protected:
|
||||
void SetUp() {
|
||||
frames_received_ = 0;
|
||||
capturer_.SignalVideoFrame
|
||||
.connect(this, &MutedVideoCapturerTest::OnVideoFrame);
|
||||
}
|
||||
void OnVideoFrame(cricket::VideoCapturer* capturer,
|
||||
const cricket::VideoFrame* muted_frame) {
|
||||
EXPECT_EQ(capturer, &capturer_);
|
||||
++frames_received_;
|
||||
received_width_ = muted_frame->GetWidth();
|
||||
received_height_ = muted_frame->GetHeight();
|
||||
}
|
||||
int frames_received() { return frames_received_; }
|
||||
bool ReceivedCorrectFormat() {
|
||||
return (received_width_ == capturer_.GetCaptureFormat()->width) &&
|
||||
(received_height_ == capturer_.GetCaptureFormat()->height);
|
||||
}
|
||||
|
||||
cricket::MutedVideoCapturer capturer_;
|
||||
int frames_received_;
|
||||
cricket::VideoFormat capture_format_;
|
||||
int received_width_;
|
||||
int received_height_;
|
||||
};
|
||||
|
||||
TEST_F(MutedVideoCapturerTest, GetBestCaptureFormat) {
|
||||
cricket::VideoFormat format(640, 360, cricket::VideoFormat::FpsToInterval(30),
|
||||
cricket::FOURCC_I420);
|
||||
cricket::VideoFormat best_format;
|
||||
EXPECT_TRUE(capturer_.GetBestCaptureFormat(format, &best_format));
|
||||
EXPECT_EQ(format.width, best_format.width);
|
||||
EXPECT_EQ(format.height, best_format.height);
|
||||
EXPECT_EQ(format.interval, best_format.interval);
|
||||
EXPECT_EQ(format.fourcc, best_format.fourcc);
|
||||
}
|
||||
|
||||
TEST_F(MutedVideoCapturerTest, IsScreencast) {
|
||||
EXPECT_FALSE(capturer_.IsScreencast());
|
||||
}
|
||||
|
||||
TEST_F(MutedVideoCapturerTest, GetPreferredFourccs) {
|
||||
std::vector<uint32> fourccs;
|
||||
EXPECT_TRUE(capturer_.GetPreferredFourccs(&fourccs));
|
||||
EXPECT_EQ(fourccs.size(), 1u);
|
||||
EXPECT_TRUE(capturer_.GetPreferredFourccs(&fourccs));
|
||||
EXPECT_EQ(fourccs.size(), 1u);
|
||||
EXPECT_EQ(fourccs[0], cricket::FOURCC_I420);
|
||||
}
|
||||
|
||||
TEST_F(MutedVideoCapturerTest, Capturing) {
|
||||
cricket::VideoFormat format(640, 360, cricket::VideoFormat::FpsToInterval(30),
|
||||
cricket::FOURCC_I420);
|
||||
EXPECT_EQ(capturer_.Start(format), cricket::CS_RUNNING);
|
||||
EXPECT_EQ(capturer_.Start(format), cricket::CS_RUNNING);
|
||||
EXPECT_TRUE(capturer_.IsRunning());
|
||||
// 100 ms should be enough to receive 3 frames at FPS of 30.
|
||||
EXPECT_EQ_WAIT(frames_received(), 1, 100);
|
||||
EXPECT_TRUE(ReceivedCorrectFormat());
|
||||
capturer_.Stop();
|
||||
EXPECT_FALSE(capturer_.IsRunning());
|
||||
}
|
1285
talk/media/base/videoadapter_unittest.cc
Executable file
1285
talk/media/base/videoadapter_unittest.cc
Executable file
File diff suppressed because it is too large
Load Diff
@ -35,13 +35,14 @@
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/systeminfo.h"
|
||||
#include "talk/media/base/videoframefactory.h"
|
||||
#include "talk/media/base/videoprocessor.h"
|
||||
|
||||
#if defined(HAVE_WEBRTC_VIDEO)
|
||||
#include "talk/media/webrtc/webrtcvideoframe.h"
|
||||
#include "talk/media/webrtc/webrtcvideoframefactory.h"
|
||||
#endif // HAVE_WEBRTC_VIDEO
|
||||
|
||||
|
||||
namespace cricket {
|
||||
|
||||
namespace {
|
||||
@ -352,10 +353,6 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
if (SignalVideoFrame.is_empty()) {
|
||||
return;
|
||||
}
|
||||
#if defined(HAVE_WEBRTC_VIDEO)
|
||||
#define VIDEO_FRAME_NAME WebRtcVideoFrame
|
||||
#endif
|
||||
#if defined(VIDEO_FRAME_NAME)
|
||||
#if !defined(DISABLE_YUV)
|
||||
if (IsScreencast()) {
|
||||
int scaled_width, scaled_height;
|
||||
@ -501,8 +498,15 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
&desired_width, &desired_height);
|
||||
}
|
||||
|
||||
VIDEO_FRAME_NAME i420_frame;
|
||||
if (!i420_frame.Alias(captured_frame, desired_width, desired_height)) {
|
||||
if (!frame_factory_) {
|
||||
LOG(LS_ERROR) << "No video frame factory.";
|
||||
return;
|
||||
}
|
||||
|
||||
rtc::scoped_ptr<VideoFrame> i420_frame(
|
||||
frame_factory_->CreateAliasedFrame(
|
||||
captured_frame, desired_width, desired_height));
|
||||
if (!i420_frame) {
|
||||
// TODO(fbarchard): LOG more information about captured frame attributes.
|
||||
LOG(LS_ERROR) << "Couldn't convert to I420! "
|
||||
<< "From " << ToString(captured_frame) << " To "
|
||||
@ -510,7 +514,7 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
return;
|
||||
}
|
||||
|
||||
VideoFrame* adapted_frame = &i420_frame;
|
||||
VideoFrame* adapted_frame = i420_frame.get();
|
||||
if (enable_video_adapter_ && !IsScreencast()) {
|
||||
VideoFrame* out_frame = NULL;
|
||||
video_adapter_.AdaptFrame(adapted_frame, &out_frame);
|
||||
@ -528,13 +532,12 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*,
|
||||
return;
|
||||
}
|
||||
if (muted_) {
|
||||
// TODO(pthatcher): Use frame_factory_->CreateBlackFrame() instead.
|
||||
adapted_frame->SetToBlack();
|
||||
}
|
||||
SignalVideoFrame(this, adapted_frame);
|
||||
|
||||
UpdateStats(captured_frame);
|
||||
|
||||
#endif // VIDEO_FRAME_NAME
|
||||
}
|
||||
|
||||
void VideoCapturer::SetCaptureState(CaptureState state) {
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "talk/media/base/mediachannel.h"
|
||||
#include "talk/media/base/videoadapter.h"
|
||||
#include "talk/media/base/videocommon.h"
|
||||
#include "talk/media/base/videoframefactory.h"
|
||||
#include "talk/media/devices/devicemanager.h"
|
||||
|
||||
|
||||
@ -289,6 +290,11 @@ class VideoCapturer
|
||||
return &video_adapter_;
|
||||
}
|
||||
|
||||
// Takes ownership.
|
||||
void set_frame_factory(VideoFrameFactory* frame_factory) {
|
||||
frame_factory_.reset(frame_factory);
|
||||
}
|
||||
|
||||
// Gets statistics for tracked variables recorded since the last call to
|
||||
// GetStats. Note that calling GetStats resets any gathered data so it
|
||||
// should be called only periodically to log statistics.
|
||||
@ -326,6 +332,7 @@ class VideoCapturer
|
||||
}
|
||||
|
||||
void SetSupportedFormats(const std::vector<VideoFormat>& formats);
|
||||
VideoFrameFactory* frame_factory() { return frame_factory_.get(); }
|
||||
|
||||
private:
|
||||
void Construct();
|
||||
@ -361,6 +368,7 @@ class VideoCapturer
|
||||
rtc::Thread* thread_;
|
||||
std::string id_;
|
||||
CaptureState capture_state_;
|
||||
rtc::scoped_ptr<VideoFrameFactory> frame_factory_;
|
||||
rtc::scoped_ptr<VideoFormat> capture_format_;
|
||||
std::vector<VideoFormat> supported_formats_;
|
||||
rtc::scoped_ptr<VideoFormat> max_format_;
|
||||
|
@ -1,4 +1,29 @@
|
||||
// Copyright 2008 Google Inc.
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
@ -13,15 +38,6 @@
|
||||
#include "talk/media/base/videocapturer.h"
|
||||
#include "talk/media/base/videoprocessor.h"
|
||||
|
||||
// If HAS_I420_FRAME is not defined the video capturer will not be able to
|
||||
// provide OnVideoFrame-callbacks since they require cricket::CapturedFrame to
|
||||
// be decoded as a cricket::VideoFrame (i.e. an I420 frame). This functionality
|
||||
// only exist if HAS_I420_FRAME is defined below. I420 frames are also a
|
||||
// requirement for the VideoProcessors so they will not be called either.
|
||||
#if defined(HAVE_WEBRTC_VIDEO)
|
||||
#define HAS_I420_FRAME
|
||||
#endif
|
||||
|
||||
using cricket::FakeVideoCapturer;
|
||||
|
||||
namespace {
|
||||
@ -682,7 +698,12 @@ TEST_F(VideoCapturerTest, TestRequest16x10_9) {
|
||||
EXPECT_EQ(360, best.height);
|
||||
}
|
||||
|
||||
#if defined(HAS_I420_FRAME)
|
||||
// If HAVE_WEBRTC_VIDEO is not defined the video capturer will not be able to
|
||||
// provide OnVideoFrame-callbacks since they require cricket::CapturedFrame to
|
||||
// be decoded as a cricket::VideoFrame (i.e. an I420 frame). This functionality
|
||||
// only exist if HAVE_WEBRTC_VIDEO is defined below. I420 frames are also a
|
||||
// requirement for the VideoProcessors so they will not be called either.
|
||||
#if defined(HAVE_WEBRTC_VIDEO)
|
||||
TEST_F(VideoCapturerTest, VideoFrame) {
|
||||
EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat(
|
||||
640,
|
||||
@ -735,7 +756,7 @@ TEST_F(VideoCapturerTest, ProcessorDropFrame) {
|
||||
EXPECT_TRUE(capturer_.CaptureFrame());
|
||||
EXPECT_EQ(0, video_frames_received());
|
||||
}
|
||||
#endif // HAS_I420_FRAME
|
||||
#endif // HAVE_WEBRTC_VIDEO
|
||||
|
||||
bool HdFormatInList(const std::vector<cricket::VideoFormat>& formats) {
|
||||
for (std::vector<cricket::VideoFormat>::const_iterator found =
|
||||
|
@ -503,14 +503,18 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
media_error_ = cricket::VideoMediaChannel::ERROR_NONE;
|
||||
channel_->SetRecvCodecs(engine_.codecs());
|
||||
EXPECT_TRUE(channel_->AddSendStream(DefaultSendStreamParams()));
|
||||
|
||||
video_capturer_.reset(new cricket::FakeVideoCapturer);
|
||||
video_capturer_.reset(CreateFakeVideoCapturer());
|
||||
cricket::VideoFormat format(640, 480,
|
||||
cricket::VideoFormat::FpsToInterval(30),
|
||||
cricket::FOURCC_I420);
|
||||
EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(format));
|
||||
EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
|
||||
}
|
||||
|
||||
virtual cricket::FakeVideoCapturer* CreateFakeVideoCapturer() {
|
||||
return new cricket::FakeVideoCapturer();
|
||||
}
|
||||
|
||||
// Utility method to setup an additional stream to send and receive video.
|
||||
// Used to test send and recv between two streams.
|
||||
void SetUpSecondStream() {
|
||||
@ -535,7 +539,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
// We dont add recv for the second stream.
|
||||
|
||||
// Setup the receive and renderer for second stream after send.
|
||||
video_capturer_2_.reset(new cricket::FakeVideoCapturer());
|
||||
video_capturer_2_.reset(CreateFakeVideoCapturer());
|
||||
cricket::VideoFormat format(640, 480,
|
||||
cricket::VideoFormat::FpsToInterval(30),
|
||||
cricket::FOURCC_I420);
|
||||
@ -967,7 +971,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
// Add an additional capturer, and hook up a renderer to receive it.
|
||||
cricket::FakeVideoRenderer renderer1;
|
||||
rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer(
|
||||
new cricket::FakeVideoCapturer);
|
||||
CreateFakeVideoCapturer());
|
||||
capturer->SetScreencast(true);
|
||||
const int kTestWidth = 160;
|
||||
const int kTestHeight = 120;
|
||||
@ -1317,7 +1321,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(SendFrame());
|
||||
EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
|
||||
rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer(
|
||||
new cricket::FakeVideoCapturer);
|
||||
CreateFakeVideoCapturer());
|
||||
capturer->SetScreencast(true);
|
||||
cricket::VideoFormat format(480, 360,
|
||||
cricket::VideoFormat::FpsToInterval(30),
|
||||
@ -1411,7 +1415,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(channel_->AddSendStream(
|
||||
cricket::StreamParams::CreateLegacy(1)));
|
||||
rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer1(
|
||||
new cricket::FakeVideoCapturer);
|
||||
CreateFakeVideoCapturer());
|
||||
capturer1->SetScreencast(true);
|
||||
EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format));
|
||||
// Set up additional stream 2.
|
||||
@ -1423,7 +1427,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
EXPECT_TRUE(channel_->AddSendStream(
|
||||
cricket::StreamParams::CreateLegacy(2)));
|
||||
rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer2(
|
||||
new cricket::FakeVideoCapturer);
|
||||
CreateFakeVideoCapturer());
|
||||
capturer2->SetScreencast(true);
|
||||
EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format));
|
||||
// State for all the streams.
|
||||
@ -1481,7 +1485,7 @@ class VideoMediaChannelTest : public testing::Test,
|
||||
// Registering an external capturer is currently the same as screen casting
|
||||
// (update the test when this changes).
|
||||
rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer(
|
||||
new cricket::FakeVideoCapturer);
|
||||
CreateFakeVideoCapturer());
|
||||
capturer->SetScreencast(true);
|
||||
const std::vector<cricket::VideoFormat>* formats =
|
||||
capturer->GetSupportedFormats();
|
||||
|
52
talk/media/base/videoframefactory.h
Executable file
52
talk/media/base/videoframefactory.h
Executable file
@ -0,0 +1,52 @@
|
||||
// libjingle
|
||||
// Copyright 2014 Google Inc.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// 3. The name of the author may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef TALK_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
|
||||
#define TALK_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
|
||||
|
||||
namespace cricket {
|
||||
|
||||
struct CapturedFrame;
|
||||
class VideoFrame;
|
||||
|
||||
// Creates cricket::VideoFrames, or a subclass of cricket::VideoFrame
|
||||
// depending on the subclass of VideoFrameFactory.
|
||||
class VideoFrameFactory {
|
||||
public:
|
||||
VideoFrameFactory() {}
|
||||
virtual ~VideoFrameFactory() {}
|
||||
|
||||
// The returned frame aliases the aliased_frame if the input color
|
||||
// space allows for aliasing, otherwise a color conversion will
|
||||
// occur. For safety, |input_frame| must outlive the returned
|
||||
// frame. Returns NULL if conversion fails.
|
||||
virtual VideoFrame* CreateAliasedFrame(
|
||||
const CapturedFrame* input_frame, int width, int height) const = 0;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_MEDIA_BASE_VIDEOFRAMEFACTORY_H_
|
@ -37,6 +37,7 @@
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "talk/media/webrtc/webrtcvideoframe.h"
|
||||
#include "talk/media/webrtc/webrtcvideoframefactory.h"
|
||||
|
||||
#include "webrtc/base/win32.h" // Need this to #include the impl files.
|
||||
#include "webrtc/modules/video_capture/include/video_capture_factory.h"
|
||||
@ -126,12 +127,14 @@ WebRtcVideoCapturer::WebRtcVideoCapturer()
|
||||
: factory_(new WebRtcVcmFactory),
|
||||
module_(NULL),
|
||||
captured_frames_(0) {
|
||||
set_frame_factory(new WebRtcVideoFrameFactory());
|
||||
}
|
||||
|
||||
WebRtcVideoCapturer::WebRtcVideoCapturer(WebRtcVcmFactoryInterface* factory)
|
||||
: factory_(factory),
|
||||
module_(NULL),
|
||||
captured_frames_(0) {
|
||||
set_frame_factory(new WebRtcVideoFrameFactory());
|
||||
}
|
||||
|
||||
WebRtcVideoCapturer::~WebRtcVideoCapturer() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2012 Google Inc.
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -25,36 +25,23 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_MEDIA_BASE_MUTEDVIDEOCAPTURER_H_
|
||||
#define TALK_MEDIA_BASE_MUTEDVIDEOCAPTURER_H_
|
||||
|
||||
#include "webrtc/base/thread.h"
|
||||
#include "talk/media/base/videocapturer.h"
|
||||
#include "talk/media/webrtc/webrtcvideoframe.h"
|
||||
#include "talk/media/webrtc/webrtcvideoframefactory.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
class MutedFramesGenerator;
|
||||
|
||||
class MutedVideoCapturer : public VideoCapturer {
|
||||
public:
|
||||
static const char kCapturerId[];
|
||||
|
||||
MutedVideoCapturer();
|
||||
virtual ~MutedVideoCapturer();
|
||||
virtual bool GetBestCaptureFormat(const VideoFormat& desired,
|
||||
VideoFormat* best_format);
|
||||
virtual CaptureState Start(const VideoFormat& capture_format);
|
||||
virtual void Stop();
|
||||
virtual bool IsRunning();
|
||||
virtual bool IsScreencast() const { return false; }
|
||||
virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs);
|
||||
|
||||
protected:
|
||||
void OnMutedFrame(VideoFrame* muted_frame);
|
||||
|
||||
rtc::scoped_ptr<MutedFramesGenerator> frame_generator_;
|
||||
};
|
||||
VideoFrame* WebRtcVideoFrameFactory::CreateAliasedFrame(
|
||||
const CapturedFrame* aliased_frame, int width, int height) const {
|
||||
// TODO(pthatcher): Move Alias logic into the VideoFrameFactory and
|
||||
// out of the VideoFrame.
|
||||
rtc::scoped_ptr<WebRtcVideoFrame> frame(new WebRtcVideoFrame());
|
||||
if (!frame->Alias(aliased_frame, width, height)) {
|
||||
LOG(LS_ERROR) <<
|
||||
"Failed to create WebRtcVideoFrame in CreateAliasedFrame.";
|
||||
return NULL;
|
||||
}
|
||||
return frame.release();
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_MEDIA_BASE_MUTEDVIDEOCAPTURER_H_
|
45
talk/media/webrtc/webrtcvideoframefactory.h
Executable file
45
talk/media/webrtc/webrtcvideoframefactory.h
Executable file
@ -0,0 +1,45 @@
|
||||
// libjingle
|
||||
// Copyright 2014 Google Inc.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// 3. The name of the author may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef TALK_MEDIA_WEBRTC_WEBRTCVIDEOFRAMEFACTORY_H_
|
||||
#define TALK_MEDIA_WEBRTC_WEBRTCVIDEOFRAMEFACTORY_H_
|
||||
|
||||
#include "talk/media/base/videoframefactory.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
struct CapturedFrame;
|
||||
|
||||
// Creates instances of cricket::WebRtcVideoFrame.
|
||||
class WebRtcVideoFrameFactory : public VideoFrameFactory {
|
||||
public:
|
||||
virtual VideoFrame* CreateAliasedFrame(
|
||||
const CapturedFrame* aliased_frame, int width, int height) const OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_MEDIA_WEBRTC_WEBRTCVIDEOFRAMEFACTORY_H_
|
Loading…
Reference in New Issue
Block a user