1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ 6 #define CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/basictypes.h" 12 #include "base/memory/ref_counted.h" 13 #include "base/memory/scoped_ptr.h" 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 15 16 class CastAudioSink; 17 class CastSession; 18 class CastVideoSink; 19 20 // A key value pair structure for codec specific parameters. 21 struct CastCodecSpecificParams { 22 std::string key; 23 std::string value; 24 25 CastCodecSpecificParams(); 26 ~CastCodecSpecificParams(); 27 }; 28 29 // Defines the basic properties of a payload supported by cast transport. 30 struct CastRtpPayloadParams { 31 // RTP specific field that identifies the content type. 32 int payload_type; 33 34 // RTP specific field to identify a stream. 35 int ssrc; 36 37 // Update frequency of payload sample. 38 int clock_rate; 39 40 // Maximum bitrate. 41 int max_bitrate; 42 43 // Minimum bitrate. 44 int min_bitrate; 45 46 // Number of audio channels. 47 int channels; 48 49 // Width and height of the video content. 50 int width; 51 int height; 52 53 // Name of the codec used. 54 std::string codec_name; 55 56 // List of codec specific parameters. 57 std::vector<CastCodecSpecificParams> codec_specific_params; 58 59 CastRtpPayloadParams(); 60 ~CastRtpPayloadParams(); 61 }; 62 63 // Defines the capabilities of the transport. 64 struct CastRtpCaps { 65 // Defines a list of supported payloads. 66 std::vector<CastRtpPayloadParams> payloads; 67 68 // Names of supported RTCP features. 69 std::vector<std::string> rtcp_features; 70 71 // Names of supported FEC (Forward Error Correction) mechanisms. 72 std::vector<std::string> fec_mechanisms; 73 74 CastRtpCaps(); 75 ~CastRtpCaps(); 76 }; 77 78 typedef CastRtpCaps CastRtpParams; 79 80 // This object represents a RTP stream that encodes and optionally 81 // encrypt audio or video data from a WebMediaStreamTrack. 82 // Note that this object does not actually output packets. It allows 83 // configuration of encoding and RTP parameters and control such a logical 84 // stream. 85 class CastRtpStream { 86 public: 87 CastRtpStream(const blink::WebMediaStreamTrack& track, 88 const scoped_refptr<CastSession>& session); 89 ~CastRtpStream(); 90 91 // Return capabilities currently supported by this transport. 92 CastRtpCaps GetCaps(); 93 94 // Return parameters set to this transport. 95 CastRtpParams GetParams(); 96 97 // Begin encoding of media stream and then submit the encoded streams 98 // to underlying transport. 99 void Start(const CastRtpParams& params); 100 101 // Stop encoding. 102 void Stop(); 103 104 private: 105 // Return true if this track is an audio track. Return false if this 106 // track is a video track. 107 bool IsAudio() const; 108 109 blink::WebMediaStreamTrack track_; 110 const scoped_refptr<CastSession> cast_session_; 111 scoped_ptr<CastAudioSink> audio_sink_; 112 scoped_ptr<CastVideoSink> video_sink_; 113 CastRtpParams params_; 114 115 DISALLOW_COPY_AND_ASSIGN(CastRtpStream); 116 }; 117 118 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ 119