blob: ba5286b3957ab284026ef490bad8f0edf819fbf3 [file] [log] [blame]
mflodman@webrtc.org06e80262013-04-18 12:02:52 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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#ifndef WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_
12#define WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_
13
14#include <string>
15#include <vector>
16
17#include "webrtc/common_types.h"
pbos@webrtc.org4988d942013-05-29 11:34:32 +000018#include "webrtc/video_engine/new_include/config.h"
19#include "webrtc/video_engine/new_include/frame_callback.h"
20#include "webrtc/video_engine/new_include/transport.h"
21#include "webrtc/video_engine/new_include/video_renderer.h"
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000022
23namespace webrtc {
24
25class VideoDecoder;
26
27namespace newapi {
28
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000029// TODO(mflodman) Move all these settings to VideoDecoder and move the
30// declaration to common_types.h.
31struct ExternalVideoDecoder {
pbos@webrtc.orgb2d1a402013-05-28 08:04:45 +000032 ExternalVideoDecoder()
33 : decoder(NULL), payload_type(0), renderer(false), expected_delay_ms(0) {}
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000034 // The actual decoder.
35 VideoDecoder* decoder;
36
37 // Received RTP packets with this payload type will be sent to this decoder
38 // instance.
39 int payload_type;
40
41 // 'true' if the decoder handles rendering as well.
42 bool renderer;
43
44 // The expected delay for decoding and rendering, i.e. the frame will be
45 // delivered this many milliseconds, if possible, earlier than the ideal
46 // render time.
47 // Note: Ignored if 'renderer' is false.
48 int expected_delay_ms;
49};
50
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000051class VideoReceiveStream {
52 public:
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +000053 struct Stats {
54 Stats()
55 : network_frame_rate(0),
56 decode_frame_rate(0),
57 render_frame_rate(0),
58 key_frames(0),
59 delta_frames(0),
60 video_packets(0),
61 retransmitted_packets(0),
62 fec_packets(0),
63 padding_packets(0),
64 discarded_packets(0),
65 received_bitrate_bps(0),
66 receive_side_delay_ms(0) {}
67 RtpStatistics rtp_stats;
68 int network_frame_rate;
69 int decode_frame_rate;
70 int render_frame_rate;
71 uint32_t key_frames;
72 uint32_t delta_frames;
73 uint32_t video_packets;
74 uint32_t retransmitted_packets;
75 uint32_t fec_packets;
76 uint32_t padding_packets;
77 uint32_t discarded_packets;
78 int32_t received_bitrate_bps;
79 int receive_side_delay_ms;
80 };
81
82 class StatsCallback {
83 public:
84 virtual ~StatsCallback() {}
85 virtual void ReceiveStats(const Stats& stats) = 0;
86 };
87
88 struct Config {
89 Config()
90 : renderer(NULL),
91 render_delay_ms(0),
92 audio_channel_id(0),
93 pre_decode_callback(NULL),
94 post_decode_callback(NULL),
95 target_delay_ms(0) {}
pbos@webrtc.orgce851092013-08-05 12:01:36 +000096 // Codecs the receive stream can receive.
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +000097 std::vector<VideoCodec> codecs;
98
99 // Receive-stream specific RTP settings.
100 struct Rtp {
101 Rtp() : ssrc(0) {}
102 // TODO(mflodman) Do we require a set ssrc? What happens if the ssrc
103 // changes?
104 uint32_t ssrc;
105
106 // See NackConfig for description.
107 NackConfig nack;
108
109 // See FecConfig for description.
110 FecConfig fec;
111
112 // RTX settings for possible payloads. RTX is disabled if the vector is
113 // empty.
114 std::vector<RtxConfig> rtx;
115
116 // RTP header extensions used for the received stream.
117 std::vector<RtpExtension> extensions;
118 } rtp;
119
120 // VideoRenderer will be called for each decoded frame. 'NULL' disables
121 // rendering of this stream.
122 VideoRenderer* renderer;
123
124 // Expected delay needed by the renderer, i.e. the frame will be delivered
125 // this many milliseconds, if possible, earlier than the ideal render time.
126 // Only valid if 'renderer' is set.
127 int render_delay_ms;
128
129 // Audio channel corresponding to this video stream, used for audio/video
130 // synchronization. 'audio_channel_id' is ignored if no VoiceEngine is set
131 // when creating the VideoEngine instance. '-1' disables a/v sync.
132 int audio_channel_id;
133
134 // Called for each incoming video frame, i.e. in encoded state. E.g. used
135 // when
136 // saving the stream to a file. 'NULL' disables the callback.
137 EncodedFrameObserver* pre_decode_callback;
138
139 // Called for each decoded frame. E.g. used when adding effects to the
140 // decoded
141 // stream. 'NULL' disables the callback.
142 I420FrameCallback* post_decode_callback;
143
144 // External video decoders to be used if incoming payload type matches the
145 // registered type for an external decoder.
146 std::vector<ExternalVideoDecoder> external_decoders;
147
148 // Target delay in milliseconds. A positive value indicates this stream is
149 // used for streaming instead of a real-time call.
150 int target_delay_ms;
151
152 // Callback for periodically receiving receiver stats.
153 StatsCallback* stats_callback;
154 };
155
mflodman@webrtc.org06e80262013-04-18 12:02:52 +0000156 virtual void StartReceive() = 0;
157 virtual void StopReceive() = 0;
158
159 // TODO(mflodman) Replace this with callback.
160 virtual void GetCurrentReceiveCodec(VideoCodec* receive_codec) = 0;
161
mflodman@webrtc.org06e80262013-04-18 12:02:52 +0000162 protected:
163 virtual ~VideoReceiveStream() {}
164};
165
166} // namespace newapi
167} // namespace webrtc
168
169#endif // WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_