mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class VideoDecoder; |
| 23 | |
| 24 | namespace newapi { |
| 25 | |
| 26 | struct 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. |
| 43 | struct RtpReceiveConfig { |
pbos@webrtc.org | b2d1a40 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 44 | RtpReceiveConfig() : ssrc(0), nack(NULL), fec(NULL) {} |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 45 | // 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. |
| 63 | struct ExternalVideoDecoder { |
pbos@webrtc.org | b2d1a40 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 64 | ExternalVideoDecoder() |
| 65 | : decoder(NULL), payload_type(0), renderer(false), expected_delay_ms(0) {} |
mflodman@webrtc.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 66 | // 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 | |
| 83 | struct VideoReceiveStreamConfig { |
pbos@webrtc.org | b2d1a40 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 84 | 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.org | 06e8026 | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 91 | // 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 | |
| 127 | class 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_ |