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 #include "content/renderer/media/webmediaplayer_impl.h" | 5 #include "content/renderer/media/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // | 111 // |
112 // Also our timers are not very accurate (especially for ogg), which becomes | 112 // Also our timers are not very accurate (especially for ogg), which becomes |
113 // evident at low speeds and on Vista. Since other speeds are risky and outside | 113 // evident at low speeds and on Vista. Since other speeds are risky and outside |
114 // the norms, we think 1/16x to 16x is a safe and useful range for now. | 114 // the norms, we think 1/16x to 16x is a safe and useful range for now. |
115 const double kMinRate = 0.0625; | 115 const double kMinRate = 0.0625; |
116 const double kMaxRate = 16.0; | 116 const double kMaxRate = 16.0; |
117 | 117 |
118 // Prefix for histograms related to Encrypted Media Extensions. | 118 // Prefix for histograms related to Encrypted Media Extensions. |
119 const char* kMediaEme = "Media.EME."; | 119 const char* kMediaEme = "Media.EME."; |
120 | 120 |
| 121 class SyncPointProviderImpl : public media::VideoFrame::SyncPointProvider { |
| 122 public: |
| 123 explicit SyncPointProviderImpl( |
| 124 blink::WebGraphicsContext3D* web_graphics_context) |
| 125 : web_graphics_context_(web_graphics_context) {} |
| 126 virtual ~SyncPointProviderImpl(); |
| 127 virtual uint32 InsertSyncPoint(); |
| 128 virtual void WaitSyncPoint(uint32 sync_point); |
| 129 |
| 130 private: |
| 131 blink::WebGraphicsContext3D* web_graphics_context_; |
| 132 }; |
| 133 |
| 134 SyncPointProviderImpl::~SyncPointProviderImpl() { |
| 135 } |
| 136 |
| 137 uint32 SyncPointProviderImpl::InsertSyncPoint() { |
| 138 return web_graphics_context_->insertSyncPoint(); |
| 139 } |
| 140 |
| 141 void SyncPointProviderImpl::WaitSyncPoint(uint32 sync_point) { |
| 142 web_graphics_context_->waitSyncPoint(sync_point); |
| 143 } |
| 144 |
121 } // namespace | 145 } // namespace |
122 | 146 |
123 namespace content { | 147 namespace content { |
124 | 148 |
125 class BufferedDataSourceHostImpl; | 149 class BufferedDataSourceHostImpl; |
126 | 150 |
127 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 151 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
128 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::CORSMode ## name) == \ | 152 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::CORSMode ## name) == \ |
129 static_cast<int>(BufferedResourceLoader::k ## name), \ | 153 static_cast<int>(BufferedResourceLoader::k ## name), \ |
130 mismatching_enums) | 154 mismatching_enums) |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 type); | 665 type); |
642 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 666 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
643 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 667 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
644 false); | 668 false); |
645 | 669 |
646 // Restore the state for TEXTURE_2D binding point as mentioned above. | 670 // Restore the state for TEXTURE_2D binding point as mentioned above. |
647 web_graphics_context->bindTexture(GL_TEXTURE_2D, texture); | 671 web_graphics_context->bindTexture(GL_TEXTURE_2D, texture); |
648 | 672 |
649 web_graphics_context->deleteTexture(source_texture); | 673 web_graphics_context->deleteTexture(source_texture); |
650 web_graphics_context->flush(); | 674 web_graphics_context->flush(); |
651 video_frame->AppendReleaseSyncPoint(web_graphics_context->insertSyncPoint()); | 675 |
| 676 SyncPointProviderImpl provider(web_graphics_context); |
| 677 video_frame->UpdateReleaseSyncPoint(provider); |
652 return true; | 678 return true; |
653 } | 679 } |
654 | 680 |
655 // Helper functions to report media EME related stats to UMA. They follow the | 681 // Helper functions to report media EME related stats to UMA. They follow the |
656 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and | 682 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and |
657 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is | 683 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is |
658 // that UMA_* macros require the names to be constant throughout the process' | 684 // that UMA_* macros require the names to be constant throughout the process' |
659 // lifetime. | 685 // lifetime. |
660 static void EmeUMAHistogramEnumeration(const std::string& key_system, | 686 static void EmeUMAHistogramEnumeration(const std::string& key_system, |
661 const std::string& method, | 687 const std::string& method, |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 compositor_task_runner_->PostTask(FROM_HERE, | 1373 compositor_task_runner_->PostTask(FROM_HERE, |
1348 base::Bind(&GetCurrentFrameAndSignal, | 1374 base::Bind(&GetCurrentFrameAndSignal, |
1349 base::Unretained(compositor_), | 1375 base::Unretained(compositor_), |
1350 &video_frame, | 1376 &video_frame, |
1351 &event)); | 1377 &event)); |
1352 event.Wait(); | 1378 event.Wait(); |
1353 return video_frame; | 1379 return video_frame; |
1354 } | 1380 } |
1355 | 1381 |
1356 } // namespace content | 1382 } // namespace content |
OLD | NEW |