blob: 77f96260c1dc11855741f63da66dd5ac3eadf2d8 [file] [log] [blame]
Ben Murdocheb525c52013-07-10 11:40:50 +01001// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_RENDERER_MEDIA_RTC_ENCODING_VIDEO_CAPTURER_H_
6#define CONTENT_RENDERER_MEDIA_RTC_ENCODING_VIDEO_CAPTURER_H_
7
8#include "base/memory/ref_counted.h"
9#include "media/video/encoded_video_source.h"
10#include "media/video/video_encode_types.h"
11#include "third_party/libjingle/source/talk/media/webrtc/webrtcvie.h"
12
13namespace content {
14
15// Class to represent an encoding capable video capture interface for the
16// WebRTC component. This class expects to be registered as an encoder with
17// an internal source to the WebRTC stack and will not be able to function as
18// an encoder for uncompressed video frames.
19class RtcEncodingVideoCapturer : public webrtc::VideoEncoder {
20 public:
21 RtcEncodingVideoCapturer(media::EncodedVideoSource* encoded_video_source,
22 webrtc::VideoCodecType codec_type);
23 virtual ~RtcEncodingVideoCapturer();
24
25 // webrtc::VideoEncoder implementation.
26 virtual int32_t InitEncode(const webrtc::VideoCodec* codecSettings,
27 int32_t numberOfCores,
28 uint32_t maxPayloadSize) OVERRIDE;
29 virtual int32_t Encode(
30 const webrtc::I420VideoFrame& /* inputImage */,
31 const webrtc::CodecSpecificInfo* codecSpecificInfo,
32 const std::vector<webrtc::VideoFrameType>* frame_types) OVERRIDE;
33 virtual int32_t RegisterEncodeCompleteCallback(
34 webrtc::EncodedImageCallback* callback) OVERRIDE;
35 virtual int32_t Release() OVERRIDE;
36 virtual int32_t SetChannelParameters(uint32_t /* packetLoss */,
37 int rtt_in_ms) OVERRIDE;
38 virtual int32_t SetRates(uint32_t newBitRate,
39 uint32_t frameRate) OVERRIDE;
40 private:
41 // Forward declaration for private implementation to represent the
42 // encoded video source client;
43 class EncodedVideoSourceClient;
44 scoped_ptr<EncodedVideoSourceClient> encoded_video_source_client_;
45
46 // Pointer to the underlying EncodedVideoSource object. It is guaranteed to
47 // outlive the RtcEncodingVideoCapturer.
48 media::EncodedVideoSource* encoded_video_source_;
49 webrtc::VideoCodecType rtc_codec_type_;
50
51 DISALLOW_COPY_AND_ASSIGN(RtcEncodingVideoCapturer);
52};
53
54} // namespace content
55
56#endif // CONTENT_RENDERER_MEDIA_RTC_ENCODING_VIDEO_CAPTURER_H_