| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // Stops the source (by calling DoStopSource()). This sets the | 46 // Stops the source (by calling DoStopSource()). This sets the |
| 47 // WebMediaStreamSource::readyState to ended, triggers the |stop_callback_| | 47 // WebMediaStreamSource::readyState to ended, triggers the |stop_callback_| |
| 48 // if set. All pointers to this object are invalid after calling this. | 48 // if set. All pointers to this object are invalid after calling this. |
| 49 void StopSource(); | 49 void StopSource(); |
| 50 | 50 |
| 51 void ResetSourceStoppedCallback() { | 51 void ResetSourceStoppedCallback() { |
| 52 DCHECK(!stop_callback_.is_null()); | 52 DCHECK(!stop_callback_.is_null()); |
| 53 stop_callback_.Reset(); | 53 stop_callback_.Reset(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 protected: | |
| 57 // Called when StopSource is called. It allows derived classes to implement | |
| 58 // its own Stop method. | |
| 59 virtual void DoStopSource() = 0; | |
| 60 | |
| 61 // Sets device information about a source that has been created by a | 56 // Sets device information about a source that has been created by a |
| 62 // JavaScript call to GetUserMedia. F.E a camera or microphone. | 57 // JavaScript call to GetUserMedia. F.E a camera or microphone. |
| 63 void SetDeviceInfo(const StreamDeviceInfo& device_info) { | 58 void SetDeviceInfo(const StreamDeviceInfo& device_info) { |
| 64 device_info_ = device_info; | 59 device_info_ = device_info; |
| 65 } | 60 } |
| 66 | 61 |
| 67 // Sets a callback that will be triggered when StopSource is called. | 62 // Sets a callback that will be triggered when StopSource is called. |
| 68 void SetStopCallback(const SourceStoppedCallback& stop_callback) { | 63 void SetStopCallback(const SourceStoppedCallback& stop_callback) { |
| 69 DCHECK(stop_callback_.is_null()); | 64 DCHECK(stop_callback_.is_null()); |
| 70 stop_callback_ = stop_callback; | 65 stop_callback_ = stop_callback; |
| 71 } | 66 } |
| 72 | 67 |
| 68 protected: |
| 69 // Called when StopSource is called. It allows derived classes to implement |
| 70 // its own Stop method. |
| 71 virtual void DoStopSource() = 0; |
| 72 |
| 73 private: | 73 private: |
| 74 StreamDeviceInfo device_info_; | 74 StreamDeviceInfo device_info_; |
| 75 SourceStoppedCallback stop_callback_; | 75 SourceStoppedCallback stop_callback_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(MediaStreamSource); | 77 DISALLOW_COPY_AND_ASSIGN(MediaStreamSource); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace content | 80 } // namespace content |
| 81 | 81 |
| 82 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ | 82 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ |
| OLD | NEW |