mflodman@webrtc.org | 65f995a | 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_COMMON_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_COMMON_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | |
| 16 | #include "webrtc/common_types.h" |
| 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | class I420VideoFrame; |
| 21 | |
| 22 | namespace newapi { |
| 23 | |
| 24 | struct EncodedFrame; |
| 25 | |
| 26 | class I420FrameCallback { |
| 27 | public: |
| 28 | // This function is called with a I420 frame allowing the user to modify the |
| 29 | // frame content. |
| 30 | virtual void FrameCallback(I420VideoFrame* video_frame) = 0; |
| 31 | |
| 32 | protected: |
| 33 | virtual ~I420FrameCallback() {} |
| 34 | }; |
| 35 | |
| 36 | class EncodedFrameObserver { |
| 37 | public: |
| 38 | virtual void EncodedFrameCallback(const EncodedFrame& encoded_frame) = 0; |
| 39 | |
| 40 | protected: |
| 41 | virtual ~EncodedFrameObserver() {} |
| 42 | }; |
| 43 | |
| 44 | class VideoRenderer { |
| 45 | public: |
| 46 | // This function should return as soon as possible and not block until it's |
| 47 | // time to render the frame. |
| 48 | // TODO(mflodman) Remove time_to_render_ms when I420VideoFrame contains NTP. |
| 49 | virtual void RenderFrame(const I420VideoFrame& video_frame, |
| 50 | int time_to_render_ms) = 0; |
| 51 | |
| 52 | protected: |
| 53 | virtual ~VideoRenderer() {} |
| 54 | }; |
| 55 | |
| 56 | class Transport { |
| 57 | public: |
| 58 | virtual bool SendRTP(const void* packet, size_t length) = 0; |
| 59 | virtual bool SendRTCP(const void* packet, size_t length) = 0; |
| 60 | |
| 61 | protected: |
| 62 | virtual ~Transport() {} |
| 63 | }; |
| 64 | |
| 65 | struct RtpStatistics { |
pbos@webrtc.org | eceb532 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 66 | RtpStatistics() |
| 67 | : ssrc(0), |
| 68 | fraction_loss(0), |
| 69 | cumulative_loss(0), |
| 70 | extended_max_sequence_number(0) {} |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 71 | uint32_t ssrc; |
| 72 | int fraction_loss; |
| 73 | int cumulative_loss; |
| 74 | int extended_max_sequence_number; |
| 75 | std::string c_name; |
| 76 | }; |
| 77 | |
pbos@webrtc.org | eceb532 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 78 | // RTCP mode to use. Compound mode is described by RFC 4585 and reduced-size |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 79 | // RTCP mode is described by RFC 5506. |
| 80 | enum RtcpMode { |
| 81 | kRtcpCompound, |
| 82 | kRtcpReducedSize |
| 83 | }; |
| 84 | |
| 85 | // Settings for NACK, see RFC 4585 for details. |
| 86 | struct NackConfig { |
pbos@webrtc.org | eceb532 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 87 | NackConfig() : rtp_history_ms(0) {} |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 88 | // Send side: the time RTP packets are stored for retransmissions. |
| 89 | // Receive side: the time the receiver is prepared to wait for |
| 90 | // retransmissions. |
pbos@webrtc.org | eceb532 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 91 | // Set to '0' to disable. |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 92 | int rtp_history_ms; |
| 93 | }; |
| 94 | |
| 95 | // Settings for forward error correction, see RFC 5109 for details. Set the |
| 96 | // payload types to '-1' to disable. |
| 97 | struct FecConfig { |
pbos@webrtc.org | eceb532 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 98 | FecConfig() : ulpfec_payload_type(-1), red_payload_type(-1) {} |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 99 | // Payload type used for ULPFEC packets. |
| 100 | int ulpfec_payload_type; |
| 101 | |
| 102 | // Payload type used for RED packets. |
| 103 | int red_payload_type; |
| 104 | }; |
| 105 | |
| 106 | // Settings for RTP retransmission payload format, see RFC 4588 for details. |
| 107 | struct RtxConfig { |
pbos@webrtc.org | eceb532 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 108 | RtxConfig() : ssrc(0), rtx_payload_type(0), video_payload_type(0) {} |
| 109 | // SSRC to use for the RTX stream. |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 110 | uint32_t ssrc; |
| 111 | |
| 112 | // Payload type to use for the RTX stream. |
| 113 | int rtx_payload_type; |
| 114 | |
| 115 | // Original video payload this RTX stream is used for. |
| 116 | int video_payload_type; |
| 117 | }; |
| 118 | |
| 119 | // RTP header extension to use for the video stream, see RFC 5285. |
| 120 | struct RtpExtension { |
pbos@webrtc.org | eceb532 | 2013-05-28 08:04:45 +0000 | [diff] [blame^] | 121 | RtpExtension() : id(0) {} |
mflodman@webrtc.org | 65f995a | 2013-04-18 12:02:52 +0000 | [diff] [blame] | 122 | // TODO(mflodman) Add API to query supported extensions. |
| 123 | std::string name; |
| 124 | int id; |
| 125 | }; |
| 126 | |
| 127 | } // namespace newapi |
| 128 | } // namespace webrtc |
| 129 | |
| 130 | #endif // WEBRTC_VIDEO_ENGINE_NEW_INCLUDE_COMMON_H_ |