| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "content/common/content_export.h" |
| 11 #include "content/common/media/media_stream_options.h" |
| 12 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 13 |
| 14 namespace blink { |
| 15 class WebMediaStreamTrack; |
| 16 } // namespace blink |
| 17 |
| 18 namespace content { |
| 19 |
| 20 class CONTENT_EXPORT MediaStreamSource |
| 21 : NON_EXPORTED_BASE(public blink::WebMediaStreamSource::ExtraData) { |
| 22 public: |
| 23 typedef base::Callback<void(const blink::WebMediaStreamSource& source)> |
| 24 SourceStopCallback; |
| 25 |
| 26 typedef base::Callback<void(MediaStreamSource* source, |
| 27 bool success)> ConstraintsCallback; |
| 28 |
| 29 MediaStreamSource(); |
| 30 virtual ~MediaStreamSource(); |
| 31 |
| 32 virtual void AddTrack(const blink::WebMediaStreamTrack& track) {}; |
| 33 virtual void RemoveTrack(const blink::WebMediaStreamTrack& track) {}; |
| 34 virtual void ApplyConstraints(const blink::WebMediaStreamTrack& track, |
| 35 const blink::WebMediaConstraints& constraints, |
| 36 const ConstraintsCallback& callback); |
| 37 |
| 38 // Return device information about the camera or microphone. |
| 39 const StreamDeviceInfo& device_info() const { |
| 40 return device_info_; |
| 41 } |
| 42 |
| 43 void OnLocalSourceStop(); |
| 44 |
| 45 protected: |
| 46 // Called when OnLocalsSource is called. |
| 47 virtual void DoStopSource() = 0; |
| 48 |
| 49 // Set device information about the camera or microphone. |
| 50 void SetDeviceInfo(const StreamDeviceInfo& device_info) { |
| 51 device_info_ = device_info; |
| 52 } |
| 53 |
| 54 // Set a callback that is triggered when OnLocalSourceStop is called. |
| 55 void SetStopCallback(const SourceStopCallback& stop_callback) { |
| 56 DCHECK(stop_callback_.is_null()); |
| 57 stop_callback_ = stop_callback; |
| 58 } |
| 59 |
| 60 private: |
| 61 StreamDeviceInfo device_info_; |
| 62 |
| 63 SourceStopCallback stop_callback_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(MediaStreamSource); |
| 66 }; |
| 67 |
| 68 } // namespace content |
| 69 |
| 70 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ |
| OLD | NEW |