Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/renderer/media/cast_session_delegate.h

Issue 883293005: Cast: Basic cast_receiver API for chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra BUILD.gn line Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/media/cast_session.cc ('k') | chrome/renderer/media/cast_session_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ 5 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_
6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ 6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 class CastEnvironment; 32 class CastEnvironment;
33 class FrameInput; 33 class FrameInput;
34 class RawEventSubscriberBundle; 34 class RawEventSubscriberBundle;
35 35
36 namespace transport { 36 namespace transport {
37 class CastTransportSender; 37 class CastTransportSender;
38 } // namespace transport 38 } // namespace transport
39 } // namespace cast 39 } // namespace cast
40 } // namespace media 40 } // namespace media
41 41
42 // Breaks out functionality that is common between CastSessionDelegate and
43 // CastReceiverSessionDelegate.
44 class CastSessionDelegateBase {
45 public:
46 CastSessionDelegateBase();
47 virtual ~CastSessionDelegateBase();
48
49 // This will start the session by configuring and creating the Cast transport
50 // and the Cast sender.
51 // Must be called before initialization of audio or video.
52 void StartUDP(const net::IPEndPoint& local_endpoint,
53 const net::IPEndPoint& remote_endpoint,
54 scoped_ptr<base::DictionaryValue> options);
55
56 protected:
57 void StatusNotificationCB(
58 media::cast::CastTransportStatus status);
59
60 virtual void ReceivePacket(scoped_ptr<media::cast::Packet> packet) = 0;
61 virtual void LogRawEvents(
62 const std::vector<media::cast::PacketEvent>& packet_events,
63 const std::vector<media::cast::FrameEvent>& frame_events) = 0;
64
65 base::ThreadChecker thread_checker_;
66 scoped_refptr<media::cast::CastEnvironment> cast_environment_;
67 scoped_ptr<media::cast::CastTransportSender> cast_transport_;
68
69 // Proxy to the IO message loop.
70 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
71 base::WeakPtrFactory<CastSessionDelegateBase> weak_factory_;
72
73 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegateBase);
74 };
75
42 // This class hosts CastSender and connects it to audio/video frame input 76 // This class hosts CastSender and connects it to audio/video frame input
43 // and network socket. 77 // and network socket.
44 // This class is created on the render thread and destroyed on the IO 78 // This class is created on the render thread and destroyed on the IO
45 // thread. All methods are accessible only on the IO thread. 79 // thread. All methods are accessible only on the IO thread.
46 class CastSessionDelegate { 80 class CastSessionDelegate : public CastSessionDelegateBase {
47 public: 81 public:
48 typedef base::Callback<void(const scoped_refptr< 82 typedef base::Callback<void(const scoped_refptr<
49 media::cast::AudioFrameInput>&)> AudioFrameInputAvailableCallback; 83 media::cast::AudioFrameInput>&)> AudioFrameInputAvailableCallback;
50 typedef base::Callback<void(const scoped_refptr< 84 typedef base::Callback<void(const scoped_refptr<
51 media::cast::VideoFrameInput>&)> VideoFrameInputAvailableCallback; 85 media::cast::VideoFrameInput>&)> VideoFrameInputAvailableCallback;
52 typedef base::Callback<void(scoped_ptr<base::BinaryValue>)> EventLogsCallback; 86 typedef base::Callback<void(scoped_ptr<base::BinaryValue>)> EventLogsCallback;
53 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> StatsCallback; 87 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> StatsCallback;
54 typedef base::Callback<void(const std::string&)> ErrorCallback; 88 typedef base::Callback<void(const std::string&)> ErrorCallback;
55 89
56 CastSessionDelegate(); 90 CastSessionDelegate();
57 virtual ~CastSessionDelegate(); 91 ~CastSessionDelegate() override;
58 92
59 // This will start the session by configuring and creating the Cast transport 93 void StartUDP(const net::IPEndPoint& local_endpoint,
60 // and the Cast sender. 94 const net::IPEndPoint& remote_endpoint,
61 // Must be called before initialization of audio or video.
62 void StartUDP(const net::IPEndPoint& remote_endpoint,
63 scoped_ptr<base::DictionaryValue> options); 95 scoped_ptr<base::DictionaryValue> options);
64 96
65 // After calling StartAudio() or StartVideo() encoding of that media will 97 // After calling StartAudio() or StartVideo() encoding of that media will
66 // begin as soon as data is delivered to its sink, if the second method is 98 // begin as soon as data is delivered to its sink, if the second method is
67 // called the first media will be restarted. It is strongly recommended not to 99 // called the first media will be restarted. It is strongly recommended not to
68 // deliver any data between calling the two methods. 100 // deliver any data between calling the two methods.
69 // It's OK to call only one of the two methods. 101 // It's OK to call only one of the two methods.
70 // StartUDP must be called before these methods. 102 // StartUDP must be called before these methods.
71 void StartAudio(const media::cast::AudioSenderConfig& config, 103 void StartAudio(const media::cast::AudioSenderConfig& config,
72 const AudioFrameInputAvailableCallback& callback, 104 const AudioFrameInputAvailableCallback& callback,
(...skipping 19 matching lines...) Expand all
92 // audio/video frames. If this is called with an error that has halted the 124 // audio/video frames. If this is called with an error that has halted the
93 // session, the |error_callback| provided to StartXXX() will be run. This 125 // session, the |error_callback| provided to StartXXX() will be run. This
94 // method may be called multiple times during the session to indicate codec 126 // method may be called multiple times during the session to indicate codec
95 // re-initializations are taking place and/or runtime errors have occurred. 127 // re-initializations are taking place and/or runtime errors have occurred.
96 void OnOperationalStatusChange( 128 void OnOperationalStatusChange(
97 bool is_for_audio, 129 bool is_for_audio,
98 const ErrorCallback& error_callback, 130 const ErrorCallback& error_callback,
99 media::cast::OperationalStatus result); 131 media::cast::OperationalStatus result);
100 132
101 private: 133 private:
102 void StatusNotificationCB( 134 void ReceivePacket(scoped_ptr<media::cast::Packet> packet) override;
103 media::cast::CastTransportStatus status);
104
105 // Adds logs collected from transport on browser side. 135 // Adds logs collected from transport on browser side.
106 void LogRawEvents(const std::vector<media::cast::PacketEvent>& packet_events, 136 void LogRawEvents(const std::vector<media::cast::PacketEvent>& packet_events,
107 const std::vector<media::cast::FrameEvent>& frame_events); 137 const std::vector<media::cast::FrameEvent>& frame_events)
138 override;
108 139
109 base::ThreadChecker thread_checker_;
110 scoped_refptr<media::cast::CastEnvironment> cast_environment_;
111 scoped_ptr<media::cast::CastSender> cast_sender_; 140 scoped_ptr<media::cast::CastSender> cast_sender_;
112 scoped_ptr<media::cast::CastTransportSender> cast_transport_;
113 141
114 AudioFrameInputAvailableCallback audio_frame_input_available_callback_; 142 AudioFrameInputAvailableCallback audio_frame_input_available_callback_;
115 VideoFrameInputAvailableCallback video_frame_input_available_callback_; 143 VideoFrameInputAvailableCallback video_frame_input_available_callback_;
116 144
117 scoped_ptr<media::cast::RawEventSubscriberBundle> event_subscribers_; 145 scoped_ptr<media::cast::RawEventSubscriberBundle> event_subscribers_;
118 146
119 // Proxy to the IO message loop.
120 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
121 base::WeakPtrFactory<CastSessionDelegate> weak_factory_; 147 base::WeakPtrFactory<CastSessionDelegate> weak_factory_;
122 148
123 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); 149 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate);
124 }; 150 };
125 151
126 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ 152 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/renderer/media/cast_session.cc ('k') | chrome/renderer/media/cast_session_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698