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

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

Issue 66293003: P2P <-> cast library integration v0.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding missing class export Created 7 years 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 | Annotate | Revision Log
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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "base/time/default_tick_clock.h" 12 #include "base/time/default_tick_clock.h"
13 #include "chrome/renderer/media/cast_session.h"
14 #include "content/public/renderer/p2p_socket_client.h"
15 #include "content/public/renderer/p2p_socket_client_delegate.h"
13 #include "media/cast/cast_config.h" 16 #include "media/cast/cast_config.h"
17 #include "media/cast/cast_sender.h"
14 18
15 namespace base { 19 namespace base {
16 class MessageLoopProxy; 20 class MessageLoopProxy;
17 } // namespace base 21 } // namespace base
18 22
19 namespace media {
20 namespace cast {
21 class CastEnvironment;
22 class CastSender;
23 } // namespace cast
24 } // namespace media
25
26 // This class hosts CastSender and connects it to audio/video frame input 23 // This class hosts CastSender and connects it to audio/video frame input
27 // and network socket. 24 // and network socket.
28 // This class is created on the render thread and destroyed on the IO 25 // This class is created on the render thread and destroyed on the IO
29 // thread. All methods are accessible only on the IO thread. 26 // thread. All methods are accessible only on the IO thread.
30 class CastSessionDelegate { 27 class CastSessionDelegate
28 : public media::cast::PacketSender,
29 public content::P2PSocketClientDelegate {
31 public: 30 public:
32 CastSessionDelegate(); 31 CastSessionDelegate();
33 ~CastSessionDelegate(); 32 virtual ~CastSessionDelegate();
33
34 void SetSocketFactory(scoped_ptr<CastSession::SocketFactory> socket_factory,
35 const net::IPEndPoint& remote_address);
34 36
35 // After calling StartAudio() and StartVideo() with configuration encoding 37 // After calling StartAudio() and StartVideo() with configuration encoding
36 // will begin. 38 // will begin.
37 void StartAudio(const media::cast::AudioSenderConfig& config); 39 void StartAudio(const media::cast::AudioSenderConfig& config);
38 void StartVideo(const media::cast::VideoSenderConfig& config); 40 void StartVideo(const media::cast::VideoSenderConfig& config);
39 41
40 private: 42 private:
41 // Start encoding threads and configure CastSender. It is ready to accept 43 // Start encoding threads and configure CastSender. It is ready to accept
42 // audio/video frames after this call. 44 // audio/video frames after this call.
43 void StartSending(); 45 void StartSending();
44 46
45 // If both audio and video are configured properly then start CastSender. 47 // If both audio and video are configured properly then start CastSender.
46 void MaybeStartSending(); 48 void MaybeStartSending();
47 49
50 // media::cast::PacketSender Implementation
51 virtual bool SendPacket(const media::cast::Packet& packet) OVERRIDE;
52 virtual bool SendPackets(const media::cast::PacketList& packets) OVERRIDE;
53
54 // content::P2PSocketClient::Delegate Implementation
55 virtual void OnOpen(const net::IPEndPoint& address) OVERRIDE;
56 virtual void OnIncomingTcpConnection(
57 const net::IPEndPoint& address,
58 content::P2PSocketClient* client) OVERRIDE;
59 virtual void OnSendComplete() OVERRIDE;
60 virtual void OnError() OVERRIDE;
61 virtual void OnDataReceived(const net::IPEndPoint& address,
62 const std::vector<char>& data) OVERRIDE;
63 private:
48 base::ThreadChecker thread_checker_; 64 base::ThreadChecker thread_checker_;
49 scoped_refptr<media::cast::CastEnvironment> cast_environment_; 65 scoped_refptr<media::cast::CastEnvironment> cast_environment_;
50 scoped_ptr<media::cast::CastSender> cast_sender_; 66 scoped_ptr<media::cast::CastSender> cast_sender_;
67 scoped_ptr<CastSession::SocketFactory> socket_factory_;
68 net::IPEndPoint remote_address_;
69 scoped_refptr<content::P2PSocketClient> socket_;
51 70
52 // Utilities threads owned by this class. They are used by CastSender for 71 // Utilities threads owned by this class. They are used by CastSender for
53 // encoding. 72 // encoding.
54 // TODO(hclam): See crbug.com/317006 for more details. 73 // TODO(hclam): See crbug.com/317006 for more details.
55 // This class shouldn't create and own threads. 74 // This class shouldn't create and own threads.
56 base::Thread audio_encode_thread_; 75 base::Thread audio_encode_thread_;
57 base::Thread video_encode_thread_; 76 base::Thread video_encode_thread_;
58 77
59 // Clock used by CastSender. 78 // Clock used by CastSender.
60 base::DefaultTickClock clock_; 79 base::DefaultTickClock clock_;
61 80
62 // Configuration for audio and video. 81 // Configuration for audio and video.
63 media::cast::AudioSenderConfig audio_config_; 82 media::cast::AudioSenderConfig audio_config_;
64 media::cast::VideoSenderConfig video_config_; 83 media::cast::VideoSenderConfig video_config_;
65 bool audio_configured_; 84 bool audio_configured_;
66 bool video_configured_; 85 bool video_configured_;
67 86
68 // Proxy to the IO message loop. 87 // Proxy to the IO message loop.
69 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 88 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
70 89
71 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); 90 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate);
72 }; 91 };
73 92
74 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ 93 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698