Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / renderer / media / cast_rtp_stream.h
bloba9fe5edcb9a14cf6b01edc6edd4c7bf8943c993f
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.
5 #ifndef CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_
6 #define CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_
8 #include <string>
9 #include <vector>
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"
16 class CastAudioSink;
17 class CastSession;
18 class CastVideoSink;
20 // A key value pair structure for codec specific parameters.
21 struct CastCodecSpecificParams {
22 std::string key;
23 std::string value;
25 CastCodecSpecificParams();
26 ~CastCodecSpecificParams();
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;
34 // RTP specific field to identify a stream.
35 int ssrc;
37 // RTP specific field to idenfity the feedback stream.
38 int feedback_ssrc;
40 // Update frequency of payload sample.
41 int clock_rate;
43 // Maximum bitrate.
44 int max_bitrate;
46 // Minimum bitrate.
47 int min_bitrate;
49 // Number of audio channels.
50 int channels;
52 // Width and height of the video content.
53 int width;
54 int height;
56 // Name of the codec used.
57 std::string codec_name;
59 // AES encryption key.
60 std::string aes_key;
62 // AES encryption IV mask.
63 std::string aes_iv_mask;
65 // List of codec specific parameters.
66 std::vector<CastCodecSpecificParams> codec_specific_params;
68 CastRtpPayloadParams();
69 ~CastRtpPayloadParams();
72 // Defines the parameters of a RTP stream.
73 struct CastRtpParams {
74 explicit CastRtpParams(const CastRtpPayloadParams& payload_params);
76 // Payload parameters.
77 CastRtpPayloadParams payload;
79 // Names of supported RTCP features.
80 std::vector<std::string> rtcp_features;
82 CastRtpParams();
83 ~CastRtpParams();
86 // This object represents a RTP stream that encodes and optionally
87 // encrypt audio or video data from a WebMediaStreamTrack.
88 // Note that this object does not actually output packets. It allows
89 // configuration of encoding and RTP parameters and control such a logical
90 // stream.
91 class CastRtpStream {
92 public:
93 CastRtpStream(const blink::WebMediaStreamTrack& track,
94 const scoped_refptr<CastSession>& session);
95 ~CastRtpStream();
97 // Return parameters currently supported by this stream.
98 std::vector<CastRtpParams> GetSupportedParams();
100 // Return parameters set to this stream.
101 CastRtpParams GetParams();
103 // Begin encoding of media stream and then submit the encoded streams
104 // to underlying transport.
105 void Start(const CastRtpParams& params);
107 // Stop encoding.
108 void Stop();
110 private:
111 // Return true if this track is an audio track. Return false if this
112 // track is a video track.
113 bool IsAudio() const;
115 blink::WebMediaStreamTrack track_;
116 const scoped_refptr<CastSession> cast_session_;
117 scoped_ptr<CastAudioSink> audio_sink_;
118 scoped_ptr<CastVideoSink> video_sink_;
119 CastRtpParams params_;
121 DISALLOW_COPY_AND_ASSIGN(CastRtpStream);
124 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_