blob: f24832d2d69d3782ec7d97944dea787389ba808f [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
stefan@webrtc.org439be292012-02-16 14:45:37 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11// This sub-API supports the following functionalities:
12// - Setting send and receive codecs.
13// - Codec specific settings.
14// - Key frame signaling.
15// - Stream management settings.
16
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000017#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CODEC_H_
18#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CODEC_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000019
20#include "common_types.h"
21
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000022namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24class VideoEngine;
25struct VideoCodec;
26
niklase@google.com470e71d2011-07-07 08:21:25 +000027// This class declares an abstract interface for a user defined observer. It is
28// up to the VideoEngine user to implement a derived class which implements the
29// observer class. The observer is registered using RegisterEncoderObserver()
30// and deregistered using DeregisterEncoderObserver().
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000031class WEBRTC_DLLEXPORT ViEEncoderObserver {
32 public:
33 // This method is called once per second with the current encoded frame rate
34 // and bit rate.
35 virtual void OutgoingRate(const int video_channel,
36 const unsigned int framerate,
37 const unsigned int bitrate) = 0;
38 protected:
39 virtual ~ViEEncoderObserver() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000040};
41
niklase@google.com470e71d2011-07-07 08:21:25 +000042// This class declares an abstract interface for a user defined observer. It is
43// up to the VideoEngine user to implement a derived class which implements the
44// observer class. The observer is registered using RegisterDecoderObserver()
45// and deregistered using DeregisterDecoderObserver().
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000046class WEBRTC_DLLEXPORT ViEDecoderObserver {
47 public:
48 // This method is called when a new incoming stream is detected, normally
49 // triggered by a new incoming SSRC or payload type.
50 virtual void IncomingCodecChanged(const int video_channel,
51 const VideoCodec& video_codec) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000052
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000053 // This method is called once per second containing the frame rate and bit
54 // rate for the incoming stream
55 virtual void IncomingRate(const int video_channel,
56 const unsigned int framerate,
57 const unsigned int bitrate) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000058
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000059 // This method is called when the decoder needs a new key frame from encoder
60 // on the sender.
61 virtual void RequestNewKeyFrame(const int video_channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000062
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000063 protected:
64 virtual ~ViEDecoderObserver() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000065};
66
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000067class WEBRTC_DLLEXPORT ViECodec {
68 public:
69 // Factory for the ViECodec sub‐API and increases an internal reference
70 // counter if successful. Returns NULL if the API is not supported or if
71 // construction fails.
72 static ViECodec* GetInterface(VideoEngine* video_engine);
niklase@google.com470e71d2011-07-07 08:21:25 +000073
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000074 // Releases the ViECodec sub-API and decreases an internal reference
75 // counter.
76 // Returns the new reference count. This value should be zero
77 // for all sub-API:s before the VideoEngine object can be safely deleted.
78 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000079
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000080 // Gets the number of available codecs for the VideoEngine build.
81 virtual int NumberOfCodecs() const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000082
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000083 // Gets a VideoCodec struct for a codec containing the default configuration
84 // for that codec type.
85 virtual int GetCodec(const unsigned char list_number,
86 VideoCodec& video_codec) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000087
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000088 // Sets the send codec to use for a specified channel.
89 virtual int SetSendCodec(const int video_channel,
90 const VideoCodec& video_codec) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000091
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000092 // Gets the current send codec settings.
93 virtual int GetSendCodec(const int video_channel,
94 VideoCodec& video_codec) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000095
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000096 // Prepares VideoEngine to receive a certain codec type and setting for a
97 // specified payload type.
98 virtual int SetReceiveCodec(const int video_channel,
99 const VideoCodec& video_codec) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000101 // Gets the current receive codec.
102 virtual int GetReceiveCodec(const int video_channel,
103 VideoCodec& video_codec) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000104
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000105 // This function is used to get codec configuration parameters to be
106 // signaled from the encoder to the decoder in the call setup.
107 virtual int GetCodecConfigParameters(
108 const int video_channel,
109 unsigned char config_parameters[kConfigParameterSize],
110 unsigned char& config_parameters_size) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000112 // Enables advanced scaling of the captured video stream if the stream
113 // differs from the send codec settings.
114 virtual int SetImageScaleStatus(const int video_channel,
115 const bool enable) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000116
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000117 // Gets the number of sent key frames and number of sent delta frames.
118 virtual int GetSendCodecStastistics(const int video_channel,
119 unsigned int& key_frames,
120 unsigned int& delta_frames) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000121
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000122 // Gets the number of decoded key frames and number of decoded delta frames.
123 virtual int GetReceiveCodecStastistics(const int video_channel,
124 unsigned int& key_frames,
125 unsigned int& delta_frames) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000126
mflodman@webrtc.org4aee6b62012-12-14 14:02:10 +0000127 // Estimate of the min required buffer time from the expected arrival time
128 // until rendering to get smooth playback.
129 virtual int GetReceiveSideDelay(const int video_channel,
130 int* delay_ms) const = 0;
131
stefan@webrtc.org439be292012-02-16 14:45:37 +0000132 // Gets the bitrate targeted by the video codec rate control in kbit/s.
133 virtual int GetCodecTargetBitrate(const int video_channel,
134 unsigned int* bitrate) const = 0;
135
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000136 // Gets the number of packets discarded by the jitter buffer because they
137 // arrived too late.
138 virtual unsigned int GetDiscardedPackets(const int video_channel) const = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000139
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000140 // Enables key frame request callback in ViEDecoderObserver.
141 virtual int SetKeyFrameRequestCallbackStatus(const int video_channel,
142 const bool enable) = 0;
stefan@webrtc.org791eec72011-10-11 07:53:43 +0000143
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000144 // Enables key frame requests for detected lost packets.
145 virtual int SetSignalKeyPacketLossStatus(
146 const int video_channel,
147 const bool enable,
148 const bool only_key_frames = false) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000149
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000150 // Registers an instance of a user implementation of the ViEEncoderObserver.
151 virtual int RegisterEncoderObserver(const int video_channel,
152 ViEEncoderObserver& observer) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000153
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000154 // Removes an already registered instance of ViEEncoderObserver.
155 virtual int DeregisterEncoderObserver(const int video_channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000156
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000157 // Registers an instance of a user implementation of the ViEDecoderObserver.
158 virtual int RegisterDecoderObserver(const int video_channel,
159 ViEDecoderObserver& observer) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000160
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000161 // Removes an already registered instance of ViEDecoderObserver.
162 virtual int DeregisterDecoderObserver(const int video_channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000163
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000164 // This function forces the next encoded frame to be a key frame. This is
165 // normally used when the remote endpoint only supports out‐band key frame
166 // request.
167 virtual int SendKeyFrame(const int video_channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000168
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000169 // This function makes the decoder wait for a key frame before starting to
170 // decode the incoming video stream.
171 virtual int WaitForFirstKeyFrame(const int video_channel,
172 const bool wait) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000173
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000174 protected:
175 ViECodec() {}
176 virtual ~ViECodec() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000177};
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000178
179} // namespace webrtc
180
181#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CODEC_H_