blob: a23b6b6465691c915817d9304e2373cc2151351e [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"
18#include "webrtc/video_engine/new_include/common.h"
19
20namespace webrtc {
21
22class VideoDecoder;
23
24namespace newapi {
25
26struct ReceiveStatistics {
27 RtpStatistics rtp_stats;
28 int network_frame_rate;
29 int decode_frame_rate;
30 int render_frame_rate;
31 uint32_t key_frames;
32 uint32_t delta_frames;
33 uint32_t video_packets;
34 uint32_t retransmitted_packets;
35 uint32_t fec_packets;
36 uint32_t padding_packets;
37 uint32_t discarded_packets;
38 int32_t received_bitrate_bps;
39 int receive_side_delay_ms;
40};
41
42// Receive stream specific RTP settings.
43struct RtpReceiveConfig {
pbos@webrtc.orgb2d1a402013-05-28 08:04:45 +000044 RtpReceiveConfig() : ssrc(0), nack(NULL), fec(NULL) {}
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000045 // TODO(mflodman) Do we require a set ssrc? What happens if the ssrc changes?
46 uint32_t ssrc;
47
48 // See NackConfig for description, 'NULL' disables NACK.
49 NackConfig* nack;
50
51 // See FecConfig for description, 'NULL' disables FEC.
52 FecConfig* fec;
53
54 // RTX settings for possible payloads. RTX is disabled if the vector is empty.
55 std::vector<RtxConfig> rtx;
56
57 // RTP header extensions used for the received stream.
58 std::vector<RtpExtension> rtp_extensions;
59};
60
61// TODO(mflodman) Move all these settings to VideoDecoder and move the
62// declaration to common_types.h.
63struct ExternalVideoDecoder {
pbos@webrtc.orgb2d1a402013-05-28 08:04:45 +000064 ExternalVideoDecoder()
65 : decoder(NULL), payload_type(0), renderer(false), expected_delay_ms(0) {}
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000066 // The actual decoder.
67 VideoDecoder* decoder;
68
69 // Received RTP packets with this payload type will be sent to this decoder
70 // instance.
71 int payload_type;
72
73 // 'true' if the decoder handles rendering as well.
74 bool renderer;
75
76 // The expected delay for decoding and rendering, i.e. the frame will be
77 // delivered this many milliseconds, if possible, earlier than the ideal
78 // render time.
79 // Note: Ignored if 'renderer' is false.
80 int expected_delay_ms;
81};
82
83struct VideoReceiveStreamConfig {
pbos@webrtc.orgb2d1a402013-05-28 08:04:45 +000084 VideoReceiveStreamConfig()
85 : renderer(NULL),
86 render_delay_ms(0),
87 audio_channel_id(0),
88 pre_decode_callback(NULL),
89 post_decode_callback(NULL),
90 target_delay_ms(0) {}
mflodman@webrtc.org06e80262013-04-18 12:02:52 +000091 // Codecs the receive stream
92 std::vector<VideoCodec> codecs;
93
94 RtpReceiveConfig rtp;
95
96 // VideoRenderer will be called for each decoded frame. 'NULL' disables
97 // rendering of this stream.
98 VideoRenderer* renderer;
99
100 // Expected delay needed by the renderer, i.e. the frame will be delivered
101 // this many milliseconds, if possible, earlier than the ideal render time.
102 // Only valid if 'renderer' is set.
103 int render_delay_ms;
104
105 // Audio channel corresponding to this video stream, used for audio/video
106 // synchronization. 'audio_channel_id' is ignored if no VoiceEngine is set
107 // when creating the VideoEngine instance. '-1' disables a/v sync.
108 int audio_channel_id;
109
110 // Called for each incoming video frame, i.e. in encoded state. E.g. used when
111 // saving the stream to a file. 'NULL' disables the callback.
112 EncodedFrameObserver* pre_decode_callback;
113
114 // Called for each decoded frame. E.g. used when adding effects to the decoded
115 // stream. 'NULL' disables the callback.
116 I420FrameCallback* post_decode_callback;
117
118 // External video decoders to be used if incoming payload type matches the
119 // registered type for an external decoder.
120 std::vector<ExternalVideoDecoder> external_decoders;
121
122 // Target delay in milliseconds. A positive value indicates this stream is
123 // used for streaming instead of a real-time call.
124 int target_delay_ms;
125};
126
127class VideoReceiveStream {
128 public:
129 virtual void StartReceive() = 0;
130 virtual void StopReceive() = 0;
131
132 // TODO(mflodman) Replace this with callback.
133 virtual void GetCurrentReceiveCodec(VideoCodec* receive_codec) = 0;
134
135 virtual void GetReceiveStatistics(ReceiveStatistics* statistics) = 0;
136
137 protected:
138 virtual ~VideoReceiveStream() {}
139};
140
141} // namespace newapi
142} // namespace webrtc
143
144#endif // WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_