Chromium Code Reviews| Index: content/renderer/media/webrtc/webrtc_video_source.h |
| diff --git a/content/renderer/media/webrtc/webrtc_video_source.h b/content/renderer/media/webrtc/webrtc_video_source.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..97213a59dd8807878f23b5d57e24bd5612cae52b |
| --- /dev/null |
| +++ b/content/renderer/media/webrtc/webrtc_video_source.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_SOURCE_H_ |
| +#define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_SOURCE_H_ |
| + |
| +#include "content/common/content_export.h" |
| +#include "third_party/libjingle/source/talk/app/webrtc/notifier.h" |
| +#include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h" |
| +#include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| +#include "third_party/libjingle/source/talk/base/criticalsection.h" |
| + |
| +namespace cricket { |
| +class VideoCapturer; |
| +class VideoRenderer; |
| +class VideoOptions; |
| +class VideoFrame; |
| +} |
| + |
| +namespace content { |
| + |
| +// WebRtcVideoSource implements VideoSourceInterface. |
| +// The different between this and webrtc::VideoSource is that this one gets |
|
Jói
2014/01/09 11:18:13
different between -> difference between
|
| +// frame only from the |FrameInput()| interface (i.e. there's not real capturer |
| +// attached to it) and it doesn't involve cricket stuff e.g. the |
| +// cricket::ChannelManager. |
| +// TODO(ronghuawu): Remove |GetVideoCapturer()| from |
| +// webrtc::VideoSourceInterface. Deliver video frames to media engine instead |
| +// of connecting media engine with the capturer directly. |
| +class CONTENT_EXPORT WebRtcVideoSource |
| + : NON_EXPORTED_BASE(public webrtc::Notifier<webrtc::VideoSourceInterface>), |
| + NON_EXPORTED_BASE(public sigslot::has_slots<>) { |
| + public: |
| + // Creates an instance of WebRtcVideoSource. |
| + static talk_base::scoped_refptr<WebRtcVideoSource> Create(); |
| + |
| + WebRtcVideoSource(); |
| + virtual ~WebRtcVideoSource(); |
| + |
| + // Implements webrtc::VideoSourceInterface |
| + virtual cricket::VideoCapturer* GetVideoCapturer(); |
| + virtual void AddSink(cricket::VideoRenderer* output); |
| + virtual void RemoveSink(cricket::VideoRenderer* output); |
| + virtual const cricket::VideoOptions* options() const; |
| + virtual webrtc::MediaSourceInterface::SourceState state() const; |
| + virtual cricket::VideoRenderer* FrameInput(); |
| + |
| + private: |
| + struct VideoSinkInfo { |
| + explicit VideoSinkInfo(cricket::VideoRenderer* s) |
| + : sink(s), |
| + width(0), |
| + height(0) { |
| + } |
| + cricket::VideoRenderer* sink; |
| + size_t width; |
| + size_t height; |
| + }; |
| + |
| + // Just pointers since ownership is not handed over to this class. |
| + typedef std::vector<VideoSinkInfo> VideoSinks; |
| + |
| + // Callback for frames received from the FrameInput interface. |
| + void OnVideoFrame(cricket::VideoCapturer* capturer, |
| + const cricket::VideoFrame* video_frame); |
| + |
| + void MaybeSetSize(const cricket::VideoFrame* frame); |
| + |
| + talk_base::scoped_ptr<cricket::VideoCapturer> video_capturer_; |
| + talk_base::scoped_ptr<cricket::VideoRenderer> frame_input_; |
| + cricket::VideoOptions options_; |
| + webrtc::MediaSourceInterface::SourceState state_; |
| + VideoSinks sinks_; |
| + talk_base::CriticalSection sinks_crit_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_SOURCE_H_ |