blob: 66862830801866f58bbbfa9d10fac9b134966201 [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 {
44 // TODO(mflodman) Do we require a set ssrc? What happens if the ssrc changes?
45 uint32_t ssrc;
46
47 // See NackConfig for description, 'NULL' disables NACK.
48 NackConfig* nack;
49
50 // See FecConfig for description, 'NULL' disables FEC.
51 FecConfig* fec;
52
53 // RTX settings for possible payloads. RTX is disabled if the vector is empty.
54 std::vector<RtxConfig> rtx;
55
56 // RTP header extensions used for the received stream.
57 std::vector<RtpExtension> rtp_extensions;
58};
59
60// TODO(mflodman) Move all these settings to VideoDecoder and move the
61// declaration to common_types.h.
62struct ExternalVideoDecoder {
63 // The actual decoder.
64 VideoDecoder* decoder;
65
66 // Received RTP packets with this payload type will be sent to this decoder
67 // instance.
68 int payload_type;
69
70 // 'true' if the decoder handles rendering as well.
71 bool renderer;
72
73 // The expected delay for decoding and rendering, i.e. the frame will be
74 // delivered this many milliseconds, if possible, earlier than the ideal
75 // render time.
76 // Note: Ignored if 'renderer' is false.
77 int expected_delay_ms;
78};
79
80struct VideoReceiveStreamConfig {
81 // Codecs the receive stream
82 std::vector<VideoCodec> codecs;
83
84 RtpReceiveConfig rtp;
85
86 // VideoRenderer will be called for each decoded frame. 'NULL' disables
87 // rendering of this stream.
88 VideoRenderer* renderer;
89
90 // Expected delay needed by the renderer, i.e. the frame will be delivered
91 // this many milliseconds, if possible, earlier than the ideal render time.
92 // Only valid if 'renderer' is set.
93 int render_delay_ms;
94
95 // Audio channel corresponding to this video stream, used for audio/video
96 // synchronization. 'audio_channel_id' is ignored if no VoiceEngine is set
97 // when creating the VideoEngine instance. '-1' disables a/v sync.
98 int audio_channel_id;
99
100 // Called for each incoming video frame, i.e. in encoded state. E.g. used when
101 // saving the stream to a file. 'NULL' disables the callback.
102 EncodedFrameObserver* pre_decode_callback;
103
104 // Called for each decoded frame. E.g. used when adding effects to the decoded
105 // stream. 'NULL' disables the callback.
106 I420FrameCallback* post_decode_callback;
107
108 // External video decoders to be used if incoming payload type matches the
109 // registered type for an external decoder.
110 std::vector<ExternalVideoDecoder> external_decoders;
111
112 // Target delay in milliseconds. A positive value indicates this stream is
113 // used for streaming instead of a real-time call.
114 int target_delay_ms;
115};
116
117class VideoReceiveStream {
118 public:
119 virtual void StartReceive() = 0;
120 virtual void StopReceive() = 0;
121
122 // TODO(mflodman) Replace this with callback.
123 virtual void GetCurrentReceiveCodec(VideoCodec* receive_codec) = 0;
124
125 virtual void GetReceiveStatistics(ReceiveStatistics* statistics) = 0;
126
127 protected:
128 virtual ~VideoReceiveStream() {}
129};
130
131} // namespace newapi
132} // namespace webrtc
133
134#endif // WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_VIDEO_RECEIVE_STREAM_H_