| 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 <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 12 #include "base/time/tick_clock.h" | 13 #include "base/time/tick_clock.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "media/cast/logging/log_event_dispatcher.h" | 15 #include "media/cast/logging/log_event_dispatcher.h" |
| 15 | 16 |
| 16 namespace media { | 17 namespace media { |
| 17 namespace cast { | 18 namespace cast { |
| 18 | 19 |
| 19 class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> { | 20 class CastEnvironment : public base::RefCountedThreadSafe<CastEnvironment> { |
| 20 public: | 21 public: |
| 21 // An enumeration of the cast threads. | 22 // An enumeration of the cast threads. |
| 22 enum ThreadId { | 23 enum ThreadId { |
| 23 // The main thread is where the cast system is configured and where timers | 24 // The main thread is where the cast system is configured and where timers |
| 24 // and network IO is performed. | 25 // and network IO is performed. |
| 25 MAIN, | 26 MAIN, |
| 26 // The audio thread is where all send side audio processing is done, | 27 // The audio thread is where all send side audio processing is done, |
| 27 // primarily encoding / decoding but also re-sampling. | 28 // primarily encoding / decoding but also re-sampling. |
| 28 AUDIO, | 29 AUDIO, |
| 29 // The video encoder thread is where the video processing is done. | 30 // The video encoder thread is where the video processing is done. |
| 30 VIDEO, | 31 VIDEO, |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 CastEnvironment( | 34 CastEnvironment( |
| 34 scoped_ptr<base::TickClock> clock, | 35 std::unique_ptr<base::TickClock> clock, |
| 35 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy, | 36 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy, |
| 36 scoped_refptr<base::SingleThreadTaskRunner> audio_thread_proxy, | 37 scoped_refptr<base::SingleThreadTaskRunner> audio_thread_proxy, |
| 37 scoped_refptr<base::SingleThreadTaskRunner> video_thread_proxy); | 38 scoped_refptr<base::SingleThreadTaskRunner> video_thread_proxy); |
| 38 | 39 |
| 39 // These are the same methods in message_loop.h, but are guaranteed to either | 40 // These are the same methods in message_loop.h, but are guaranteed to either |
| 40 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. | 41 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. |
| 41 // They return true iff the thread existed and the task was posted. Note that | 42 // They return true iff the thread existed and the task was posted. Note that |
| 42 // even if the task is posted, there's no guarantee that it will run, since | 43 // even if the task is posted, there's no guarantee that it will run, since |
| 43 // the target thread may already have a Quit message in its queue. | 44 // the target thread may already have a Quit message in its queue. |
| 44 bool PostTask(ThreadId identifier, | 45 bool PostTask(ThreadId identifier, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 65 | 66 |
| 66 bool HasVideoThread() { return video_thread_proxy_.get() ? true : false; } | 67 bool HasVideoThread() { return video_thread_proxy_.get() ? true : false; } |
| 67 | 68 |
| 68 protected: | 69 protected: |
| 69 virtual ~CastEnvironment(); | 70 virtual ~CastEnvironment(); |
| 70 | 71 |
| 71 // Subclasses may final these. | 72 // Subclasses may final these. |
| 72 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy_; | 73 scoped_refptr<base::SingleThreadTaskRunner> main_thread_proxy_; |
| 73 scoped_refptr<base::SingleThreadTaskRunner> audio_thread_proxy_; | 74 scoped_refptr<base::SingleThreadTaskRunner> audio_thread_proxy_; |
| 74 scoped_refptr<base::SingleThreadTaskRunner> video_thread_proxy_; | 75 scoped_refptr<base::SingleThreadTaskRunner> video_thread_proxy_; |
| 75 scoped_ptr<base::TickClock> clock_; | 76 std::unique_ptr<base::TickClock> clock_; |
| 76 LogEventDispatcher logger_; | 77 LogEventDispatcher logger_; |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 friend class base::RefCountedThreadSafe<CastEnvironment>; | 80 friend class base::RefCountedThreadSafe<CastEnvironment>; |
| 80 | 81 |
| 81 DISALLOW_COPY_AND_ASSIGN(CastEnvironment); | 82 DISALLOW_COPY_AND_ASSIGN(CastEnvironment); |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 } // namespace cast | 85 } // namespace cast |
| 85 } // namespace media | 86 } // namespace media |
| 86 | 87 |
| 87 #endif // MEDIA_CAST_CAST_ENVIRONMENT_H_ | 88 #endif // MEDIA_CAST_CAST_ENVIRONMENT_H_ |
| OLD | NEW |