| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/renderer/media/video_destination_handler.h" | 5 #include "content/renderer/media/video_destination_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "content/renderer/media/media_stream_dependency_factory.h" | 12 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 13 #include "content/renderer/media/media_stream_registry_interface.h" | 13 #include "content/renderer/media/media_stream_registry_interface.h" |
| 14 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 14 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
| 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 16 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 16 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 17 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
| 17 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | |
| 18 | 18 |
| 19 using cricket::CaptureState; | 19 using cricket::CaptureState; |
| 20 using cricket::VideoFormat; | 20 using cricket::VideoFormat; |
| 21 using webkit::ppapi::PPB_ImageData_Impl; | 21 using webkit::ppapi::PPB_ImageData_Impl; |
| 22 using webrtc::VideoTrackInterface; | 22 using webrtc::VideoTrackInterface; |
| 23 using webrtc::VideoTrackVector; | 23 using webrtc::VideoTrackVector; |
| 24 | 24 |
| 25 static const cricket::FourCC kEffectColorFormat = cricket::FOURCC_BGRA; | 25 static const cricket::FourCC kEffectColorFormat = cricket::FOURCC_BGRA; |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 best_format->interval = desired.interval; | 78 best_format->interval = desired.interval; |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool PpFrameWriter::IsScreencast() const { | 82 bool PpFrameWriter::IsScreencast() const { |
| 83 return false; | 83 return false; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void PpFrameWriter::PutFrame(PPB_ImageData_Impl* image_data, | 86 void PpFrameWriter::PutFrame(PPB_ImageData_Impl* image_data, |
| 87 int64 time_stamp_ns) { | 87 int64 time_stamp_ns) { |
| 88 #if defined(ENABLE_PLUGINS) |
| 88 base::AutoLock auto_lock(lock_); | 89 base::AutoLock auto_lock(lock_); |
| 89 // This assumes the handler of the SignalFrameCaptured won't call Start/Stop. | 90 // This assumes the handler of the SignalFrameCaptured won't call Start/Stop. |
| 90 // TODO(ronghuawu): Avoid the using of lock. One way is to post this call to | 91 // TODO(ronghuawu): Avoid the using of lock. One way is to post this call to |
| 91 // libjingle worker thread, which will require an extra copy of |image_data|. | 92 // libjingle worker thread, which will require an extra copy of |image_data|. |
| 92 // However if pepper host can hand over the ownership of |image_data| | 93 // However if pepper host can hand over the ownership of |image_data| |
| 93 // then we can avoid this extra copy. | 94 // then we can avoid this extra copy. |
| 94 if (!started_) { | 95 if (!started_) { |
| 95 LOG(ERROR) << "PpFrameWriter::PutFrame - " | 96 LOG(ERROR) << "PpFrameWriter::PutFrame - " |
| 96 << "Called when capturer is not started."; | 97 << "Called when capturer is not started."; |
| 97 return; | 98 return; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 125 } else { | 126 } else { |
| 126 LOG(ERROR) << "PpFrameWriter::PutFrame - Got RGBA which is not supported."; | 127 LOG(ERROR) << "PpFrameWriter::PutFrame - Got RGBA which is not supported."; |
| 127 return; | 128 return; |
| 128 } | 129 } |
| 129 frame.data_size = bitmap->getSize(); | 130 frame.data_size = bitmap->getSize(); |
| 130 frame.data = bitmap->getPixels(); | 131 frame.data = bitmap->getPixels(); |
| 131 | 132 |
| 132 // This signals to libJingle that a new VideoFrame is available. | 133 // This signals to libJingle that a new VideoFrame is available. |
| 133 // libJingle have no assumptions on what thread this signal come from. | 134 // libJingle have no assumptions on what thread this signal come from. |
| 134 SignalFrameCaptured(this, &frame); | 135 SignalFrameCaptured(this, &frame); |
| 136 #endif |
| 135 } | 137 } |
| 136 | 138 |
| 137 // PpFrameWriterProxy is a helper class to make sure the user won't use | 139 // PpFrameWriterProxy is a helper class to make sure the user won't use |
| 138 // PpFrameWriter after it is released (IOW its owner - WebMediaStreamTrack - | 140 // PpFrameWriter after it is released (IOW its owner - WebMediaStreamTrack - |
| 139 // is released). | 141 // is released). |
| 140 class PpFrameWriterProxy : public FrameWriterInterface { | 142 class PpFrameWriterProxy : public FrameWriterInterface { |
| 141 public: | 143 public: |
| 142 PpFrameWriterProxy(VideoTrackInterface* track, | 144 PpFrameWriterProxy(VideoTrackInterface* track, |
| 143 PpFrameWriter* writer) | 145 PpFrameWriter* writer) |
| 144 : track_(track), | 146 : track_(track), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 VideoTrackVector video_tracks = native_stream->GetVideoTracks(); | 204 VideoTrackVector video_tracks = native_stream->GetVideoTracks(); |
| 203 // Currently one supports one video track per media stream. | 205 // Currently one supports one video track per media stream. |
| 204 DCHECK(video_tracks.size() == 1); | 206 DCHECK(video_tracks.size() == 1); |
| 205 | 207 |
| 206 *frame_writer = new PpFrameWriterProxy(video_tracks[0].get(), writer); | 208 *frame_writer = new PpFrameWriterProxy(video_tracks[0].get(), writer); |
| 207 return true; | 209 return true; |
| 208 } | 210 } |
| 209 | 211 |
| 210 } // namespace content | 212 } // namespace content |
| 211 | 213 |
| OLD | NEW |