OLD | NEW |
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 MEDIA_CAST_CAST_ENVIRONMENT_H_ | 5 #ifndef MEDIA_CAST_CAST_ENVIRONMENT_H_ |
6 #define MEDIA_CAST_CAST_ENVIRONMENT_H_ | 6 #define MEDIA_CAST_CAST_ENVIRONMENT_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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 }; | 39 }; |
40 | 40 |
41 CastEnvironment( | 41 CastEnvironment( |
42 scoped_ptr<base::TickClock> clock, | 42 scoped_ptr<base::TickClock> clock, |
43 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy, | 43 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy, |
44 scoped_refptr<base::SingleThreadTaskRunner> audio_encode_thread_proxy, | 44 scoped_refptr<base::SingleThreadTaskRunner> audio_encode_thread_proxy, |
45 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_thread_proxy, | 45 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_thread_proxy, |
46 scoped_refptr<base::SingleThreadTaskRunner> video_encode_thread_proxy, | 46 scoped_refptr<base::SingleThreadTaskRunner> video_encode_thread_proxy, |
47 scoped_refptr<base::SingleThreadTaskRunner> video_decode_thread_proxy, | 47 scoped_refptr<base::SingleThreadTaskRunner> video_decode_thread_proxy, |
48 scoped_refptr<base::SingleThreadTaskRunner> transport_thread_proxy, | 48 scoped_refptr<base::SingleThreadTaskRunner> transport_thread_proxy, |
49 const CastLoggingConfig& config); | 49 const CastLoggingConfig& logging_config); |
50 | 50 |
51 // These are the same methods in message_loop.h, but are guaranteed to either | 51 // These are the same methods in message_loop.h, but are guaranteed to either |
52 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. | 52 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. |
53 // They return true iff the thread existed and the task was posted. Note that | 53 // They return true iff the thread existed and the task was posted. Note that |
54 // even if the task is posted, there's no guarantee that it will run, since | 54 // even if the task is posted, there's no guarantee that it will run, since |
55 // the target thread may already have a Quit message in its queue. | 55 // the target thread may already have a Quit message in its queue. |
56 bool PostTask(ThreadId identifier, | 56 bool PostTask(ThreadId identifier, |
57 const tracked_objects::Location& from_here, | 57 const tracked_objects::Location& from_here, |
58 const base::Closure& task); | 58 const base::Closure& task); |
59 | 59 |
60 bool PostDelayedTask(ThreadId identifier, | 60 bool PostDelayedTask(ThreadId identifier, |
61 const tracked_objects::Location& from_here, | 61 const tracked_objects::Location& from_here, |
62 const base::Closure& task, | 62 const base::Closure& task, |
63 base::TimeDelta delay); | 63 base::TimeDelta delay); |
64 | 64 |
65 bool CurrentlyOn(ThreadId identifier); | 65 bool CurrentlyOn(ThreadId identifier); |
66 | 66 |
67 base::TickClock* Clock() const; | 67 // All of the media::cast implementation must use this TickClock. |
| 68 base::TickClock* Clock() const { return clock_.get(); } |
68 | 69 |
69 // Logging is not thread safe. Should always be called from the main thread. | 70 // Logging is not thread safe. Its methods should always be called from the |
70 LoggingImpl* Logging(); | 71 // main thread. |
| 72 LoggingImpl* Logging() const { return logging_.get(); } |
71 | 73 |
72 scoped_refptr<base::SingleThreadTaskRunner> | 74 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner( |
73 GetMessageSingleThreadTaskRunnerForThread(ThreadId identifier); | 75 ThreadId identifier) const; |
74 | 76 |
75 bool HasAudioEncoderThread() { | 77 bool HasAudioEncoderThread() { |
76 return audio_encode_thread_proxy_ ? true : false; | 78 return audio_encode_thread_proxy_ ? true : false; |
77 } | 79 } |
78 | 80 |
79 bool HasVideoEncoderThread() { | 81 bool HasVideoEncoderThread() { |
80 return video_encode_thread_proxy_ ? true : false; | 82 return video_encode_thread_proxy_ ? true : false; |
81 } | 83 } |
82 | 84 |
83 protected: | 85 protected: |
84 virtual ~CastEnvironment(); | 86 virtual ~CastEnvironment(); |
85 | 87 |
86 private: | 88 // Subclasses may override these. |
87 friend class base::RefCountedThreadSafe<CastEnvironment>; | |
88 | |
89 scoped_ptr<base::TickClock> clock_; | |
90 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy_; | 89 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy_; |
91 scoped_refptr<base::SingleThreadTaskRunner> audio_encode_thread_proxy_; | 90 scoped_refptr<base::SingleThreadTaskRunner> audio_encode_thread_proxy_; |
92 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_thread_proxy_; | 91 scoped_refptr<base::SingleThreadTaskRunner> audio_decode_thread_proxy_; |
93 scoped_refptr<base::SingleThreadTaskRunner> video_encode_thread_proxy_; | 92 scoped_refptr<base::SingleThreadTaskRunner> video_encode_thread_proxy_; |
94 scoped_refptr<base::SingleThreadTaskRunner> video_decode_thread_proxy_; | 93 scoped_refptr<base::SingleThreadTaskRunner> video_decode_thread_proxy_; |
95 scoped_refptr<base::SingleThreadTaskRunner> transport_thread_proxy_; | 94 scoped_refptr<base::SingleThreadTaskRunner> transport_thread_proxy_; |
96 | 95 |
| 96 private: |
| 97 friend class base::RefCountedThreadSafe<CastEnvironment>; |
| 98 |
| 99 scoped_ptr<base::TickClock> clock_; |
97 scoped_ptr<LoggingImpl> logging_; | 100 scoped_ptr<LoggingImpl> logging_; |
98 | 101 |
99 DISALLOW_COPY_AND_ASSIGN(CastEnvironment); | 102 DISALLOW_COPY_AND_ASSIGN(CastEnvironment); |
100 }; | 103 }; |
101 | 104 |
102 } // namespace cast | 105 } // namespace cast |
103 } // namespace media | 106 } // namespace media |
104 | 107 |
105 #endif // MEDIA_CAST_CAST_ENVIRONMENT_H_ | 108 #endif // MEDIA_CAST_CAST_ENVIRONMENT_H_ |
OLD | NEW |