From eb32ba6f51d0c21d58cd7d89785285ff8fa64624 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Thu, 21 Nov 2013 14:09:57 +0100 Subject: Update chromium to branch 1599. Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb Reviewed-by: Andras Becsi --- .../media/audio/android/audio_manager_android.cc | 9 +- chromium/media/audio/clockless_audio_sink.cc | 107 ------- chromium/media/audio/clockless_audio_sink.h | 55 ---- .../src/org/chromium/media/MediaCodecBridge.java | 21 +- .../src/org/chromium/media/MediaDrmBridge.java | 338 --------------------- .../java/src/org/chromium/media/VideoCapture.java | 8 +- chromium/media/base/android/media_codec_bridge.cc | 30 +- chromium/media/base/android/media_codec_bridge.h | 4 +- chromium/media/base/android/media_drm_bridge.cc | 91 ++---- chromium/media/base/android/media_drm_bridge.h | 29 +- chromium/media/base/android/media_jni_registrar.cc | 3 - chromium/media/base/android/media_source_player.cc | 15 +- chromium/media/base/run_all_unittests.cc | 3 + chromium/media/ffmpeg/ffmpeg_regression_tests.cc | 4 +- chromium/media/filters/ffmpeg_audio_decoder.cc | 7 + .../filters/gpu_video_accelerator_factories.cc | 11 - .../filters/gpu_video_accelerator_factories.h | 73 ----- chromium/media/filters/gpu_video_decoder.cc | 9 +- chromium/media/filters/gpu_video_decoder.h | 6 +- .../media/filters/gpu_video_decoder_factories.cc | 11 + .../media/filters/gpu_video_decoder_factories.h | 67 ++++ .../mock_gpu_video_accelerator_factories.cc | 28 -- .../filters/mock_gpu_video_accelerator_factories.h | 70 ----- .../filters/mock_gpu_video_decoder_factories.cc | 13 + .../filters/mock_gpu_video_decoder_factories.h | 55 ++++ .../media/filters/pipeline_integration_test.cc | 33 +- .../filters/pipeline_integration_test_base.cc | 61 ++-- .../media/filters/pipeline_integration_test_base.h | 19 +- chromium/media/filters/stream_parser_factory.cc | 4 + chromium/media/media.gyp | 35 +-- chromium/media/tools/shader_bench/shader_bench.cc | 14 +- .../media/video/capture/win/filter_base_win.cc | 2 + chromium/media/video/capture/win/pin_base_win.cc | 2 + chromium/media/video/video_encode_accelerator.cc | 11 - chromium/media/video/video_encode_accelerator.h | 145 --------- chromium/media/webm/webm_cluster_parser.cc | 4 +- 36 files changed, 320 insertions(+), 1077 deletions(-) delete mode 100644 chromium/media/audio/clockless_audio_sink.cc delete mode 100644 chromium/media/audio/clockless_audio_sink.h delete mode 100644 chromium/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java delete mode 100644 chromium/media/filters/gpu_video_accelerator_factories.cc delete mode 100644 chromium/media/filters/gpu_video_accelerator_factories.h create mode 100644 chromium/media/filters/gpu_video_decoder_factories.cc create mode 100644 chromium/media/filters/gpu_video_decoder_factories.h delete mode 100644 chromium/media/filters/mock_gpu_video_accelerator_factories.cc delete mode 100644 chromium/media/filters/mock_gpu_video_accelerator_factories.h create mode 100644 chromium/media/filters/mock_gpu_video_decoder_factories.cc create mode 100644 chromium/media/filters/mock_gpu_video_decoder_factories.h delete mode 100644 chromium/media/video/video_encode_accelerator.cc delete mode 100644 chromium/media/video/video_encode_accelerator.h (limited to 'chromium/media') diff --git a/chromium/media/audio/android/audio_manager_android.cc b/chromium/media/audio/android/audio_manager_android.cc index 69bd2b82cd4..164344aba0b 100644 --- a/chromium/media/audio/android/audio_manager_android.cc +++ b/chromium/media/audio/android/audio_manager_android.cc @@ -59,11 +59,16 @@ void AudioManagerAndroid::GetAudioInputDeviceNames( AudioParameters AudioManagerAndroid::GetInputStreamParameters( const std::string& device_id) { + // Use mono as preferred number of input channels on Android to save + // resources. Using mono also avoids a driver issue seen on Samsung + // Galaxy S3 and S4 devices. See http://crbug.com/256851 for details. + ChannelLayout channel_layout = CHANNEL_LAYOUT_MONO; int buffer_size = Java_AudioManagerAndroid_getMinInputFrameSize( - base::android::AttachCurrentThread(), GetNativeOutputSampleRate(), 2); + base::android::AttachCurrentThread(), GetNativeOutputSampleRate(), + ChannelLayoutToChannelCount(channel_layout)); return AudioParameters( - AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, + AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, GetNativeOutputSampleRate(), 16, buffer_size <= 0 ? kDefaultInputBufferSize : buffer_size); } diff --git a/chromium/media/audio/clockless_audio_sink.cc b/chromium/media/audio/clockless_audio_sink.cc deleted file mode 100644 index ff809d0541d..00000000000 --- a/chromium/media/audio/clockless_audio_sink.cc +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/audio/clockless_audio_sink.h" - -#include "base/threading/simple_thread.h" -#include "base/time/time.h" -#include "media/base/audio_renderer_sink.h" - -namespace media { - -// Internal to ClocklessAudioSink. Class is used to call Render() on a seperate -// thread, running as fast as it can read the data. -class ClocklessAudioSinkThread : public base::DelegateSimpleThread::Delegate { - public: - explicit ClocklessAudioSinkThread(const AudioParameters& params, - AudioRendererSink::RenderCallback* callback) - : callback_(callback), - audio_bus_(AudioBus::Create(params)), - stop_event_(new base::WaitableEvent(false, false)) {} - - void Start() { - stop_event_->Reset(); - thread_.reset(new base::DelegateSimpleThread(this, "ClocklessAudioSink")); - thread_->Start(); - } - - // Generate a signal to stop calling Render(). - base::TimeDelta Stop() { - stop_event_->Signal(); - thread_->Join(); - return playback_time_; - } - - private: - // Call Render() repeatedly, keeping track of the rendering time. - virtual void Run() OVERRIDE { - base::TimeTicks start; - while (!stop_event_->IsSignaled()) { - int frames_received = callback_->Render(audio_bus_.get(), 0); - if (frames_received <= 0) { - // No data received, so let other threads run to provide data. - base::PlatformThread::YieldCurrentThread(); - } else if (start.is_null()) { - // First time we processed some audio, so record the starting time. - start = base::TimeTicks::HighResNow(); - } else { - // Keep track of the last time data was rendered. - playback_time_ = base::TimeTicks::HighResNow() - start; - } - } - } - - AudioRendererSink::RenderCallback* callback_; - scoped_ptr audio_bus_; - scoped_ptr stop_event_; - scoped_ptr thread_; - base::TimeDelta playback_time_; -}; - -ClocklessAudioSink::ClocklessAudioSink() - : initialized_(false), - playing_(false) {} - -ClocklessAudioSink::~ClocklessAudioSink() {} - -void ClocklessAudioSink::Initialize(const AudioParameters& params, - RenderCallback* callback) { - DCHECK(!initialized_); - thread_.reset(new ClocklessAudioSinkThread(params, callback)); - initialized_ = true; -} - -void ClocklessAudioSink::Start() { - DCHECK(!playing_); -} - -void ClocklessAudioSink::Stop() { - DCHECK(initialized_); - - if (!playing_) - return; - - playback_time_ = thread_->Stop(); -} - -void ClocklessAudioSink::Play() { - DCHECK(initialized_); - - if (playing_) - return; - - playing_ = true; - thread_->Start(); -} - -void ClocklessAudioSink::Pause() { - Stop(); -} - -bool ClocklessAudioSink::SetVolume(double volume) { - // Audio is always muted. - return volume == 0.0; -} - -} // namespace media diff --git a/chromium/media/audio/clockless_audio_sink.h b/chromium/media/audio/clockless_audio_sink.h deleted file mode 100644 index 9e73b1a8817..00000000000 --- a/chromium/media/audio/clockless_audio_sink.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_ -#define MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/time/time.h" -#include "media/base/audio_renderer_sink.h" - -namespace base { -class MessageLoopProxy; -} - -namespace media { -class AudioBus; -class ClocklessAudioSinkThread; - -// Implementation of an AudioRendererSink that consumes the audio as fast as -// possible. This class does not support multiple Play()/Pause() events. -class MEDIA_EXPORT ClocklessAudioSink - : NON_EXPORTED_BASE(public AudioRendererSink) { - public: - ClocklessAudioSink(); - - // AudioRendererSink implementation. - virtual void Initialize(const AudioParameters& params, - RenderCallback* callback) OVERRIDE; - virtual void Start() OVERRIDE; - virtual void Stop() OVERRIDE; - virtual void Pause() OVERRIDE; - virtual void Play() OVERRIDE; - virtual bool SetVolume(double volume) OVERRIDE; - - // Returns the time taken to consume all the audio. - base::TimeDelta render_time() { return playback_time_; } - - protected: - virtual ~ClocklessAudioSink(); - - private: - scoped_ptr thread_; - bool initialized_; - bool playing_; - - // Time taken in last set of Render() calls. - base::TimeDelta playback_time_; - - DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink); -}; - -} // namespace media - -#endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_ diff --git a/chromium/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java b/chromium/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java index ed5d9478c55..9cce93dd7c4 100644 --- a/chromium/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java +++ b/chromium/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java @@ -29,6 +29,7 @@ class MediaCodecBridge { // Error code for MediaCodecBridge. Keep this value in sync with // INFO_MEDIA_CODEC_ERROR in media_codec_bridge.h. + private static final int MEDIA_CODEC_OK = 0; private static final int MEDIA_CODEC_ERROR = -1000; // After a flush(), dequeueOutputBuffer() can often produce empty presentation timestamps @@ -115,12 +116,18 @@ class MediaCodecBridge { } @CalledByNative - private void flush() { - mMediaCodec.flush(); - mFlushed = true; - if (mAudioTrack != null) { - mAudioTrack.flush(); + private int flush() { + try { + mFlushed = true; + if (mAudioTrack != null) { + mAudioTrack.flush(); + } + mMediaCodec.flush(); + } catch(IllegalStateException e) { + Log.e(TAG, "Failed to flush MediaCodec " + e.toString()); + return MEDIA_CODEC_ERROR; } + return MEDIA_CODEC_OK; } @CalledByNative @@ -230,7 +237,7 @@ class MediaCodecBridge { } @CalledByNative - private static void setCodecSpecificData(MediaFormat format, int index, ByteBuffer bytes) { + private static void setCodecSpecificData(MediaFormat format, int index, byte[] bytes) { String name = null; if (index == 0) { name = "csd-0"; @@ -238,7 +245,7 @@ class MediaCodecBridge { name = "csd-1"; } if (name != null) { - format.setByteBuffer(name, bytes); + format.setByteBuffer(name, ByteBuffer.wrap(bytes)); } } diff --git a/chromium/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java b/chromium/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java deleted file mode 100644 index 5f824fc6128..00000000000 --- a/chromium/media/base/android/java/src/org/chromium/media/MediaDrmBridge.java +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.media; - -import android.media.MediaCrypto; -import android.media.MediaDrm; -import android.os.AsyncTask; -import android.os.Handler; -import android.util.Log; - -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.HttpClient; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.util.EntityUtils; -import org.chromium.base.CalledByNative; -import org.chromium.base.JNINamespace; - -import java.io.IOException; -import java.util.HashMap; -import java.util.UUID; - -/** - * A wrapper of the android MediaDrm class. Each MediaDrmBridge manages multiple - * sessions for a single MediaSourcePlayer. - */ -@JNINamespace("media") -class MediaDrmBridge { - - private static final String TAG = "MediaDrmBridge"; - private MediaDrm mMediaDrm; - private UUID mSchemeUUID; - private int mNativeMediaDrmBridge; - // TODO(qinmin): we currently only support one session per DRM bridge. - // Change this to a HashMap if we start to support multiple sessions. - private String mSessionId; - private MediaCrypto mMediaCrypto; - private String mMimeType; - private Handler mhandler; - - private static UUID getUUIDFromBytes(byte[] data) { - if (data.length != 16) { - return null; - } - long mostSigBits = 0; - long leastSigBits = 0; - for (int i = 0; i < 8; i++) { - mostSigBits = (mostSigBits << 8) | (data[i] & 0xff); - } - for (int i = 8; i < 16; i++) { - leastSigBits = (leastSigBits << 8) | (data[i] & 0xff); - } - return new UUID(mostSigBits, leastSigBits); - } - - private MediaDrmBridge(UUID schemeUUID, int nativeMediaDrmBridge) { - try { - mSchemeUUID = schemeUUID; - mMediaDrm = new MediaDrm(schemeUUID); - mNativeMediaDrmBridge = nativeMediaDrmBridge; - mMediaDrm.setOnEventListener(new MediaDrmListener()); - mSessionId = openSession(); - mhandler = new Handler(); - } catch (android.media.UnsupportedSchemeException e) { - Log.e(TAG, "Unsupported DRM scheme " + e.toString()); - } - } - - /** - * Open a new session and return the sessionId. - * - * @return ID of the session. - */ - private String openSession() { - String session = null; - try { - final byte[] sessionId = mMediaDrm.openSession(); - session = new String(sessionId, "UTF-8"); - } catch (android.media.NotProvisionedException e) { - Log.e(TAG, "Cannot open a new session " + e.toString()); - } catch (java.io.UnsupportedEncodingException e) { - Log.e(TAG, "Cannot open a new session " + e.toString()); - } - return session; - } - - /** - * Create a new MediaDrmBridge from the crypto scheme UUID. - * - * @param schemeUUID Crypto scheme UUID. - * @param nativeMediaDrmBridge Native object of this class. - */ - @CalledByNative - private static MediaDrmBridge create(byte[] schemeUUID, int nativeMediaDrmBridge) { - UUID cryptoScheme = getUUIDFromBytes(schemeUUID); - if (cryptoScheme != null && MediaDrm.isCryptoSchemeSupported(cryptoScheme)) { - return new MediaDrmBridge(cryptoScheme, nativeMediaDrmBridge); - } - return null; - } - - /** - * Create a new MediaCrypto object from the session Id. - * - * @param sessionId Crypto session Id. - */ - @CalledByNative - private MediaCrypto getMediaCrypto() { - if (mMediaCrypto != null) { - return mMediaCrypto; - } - try { - final byte[] session = mSessionId.getBytes("UTF-8"); - if (MediaCrypto.isCryptoSchemeSupported(mSchemeUUID)) { - mMediaCrypto = new MediaCrypto(mSchemeUUID, session); - } - } catch (android.media.MediaCryptoException e) { - Log.e(TAG, "Cannot create MediaCrypto " + e.toString()); - } catch (java.io.UnsupportedEncodingException e) { - Log.e(TAG, "Cannot create MediaCrypto " + e.toString()); - } - return mMediaCrypto; - } - - /** - * Release the MediaDrmBridge object. - */ - @CalledByNative - private void release() { - if (mMediaCrypto != null) { - mMediaCrypto.release(); - } - if (mSessionId != null) { - try { - final byte[] session = mSessionId.getBytes("UTF-8"); - mMediaDrm.closeSession(session); - } catch (java.io.UnsupportedEncodingException e) { - Log.e(TAG, "Failed to close session " + e.toString()); - } - } - mMediaDrm.release(); - } - - /** - * Generate a key request and post an asynchronous task to the native side - * with the response message. - * - * @param initData Data needed to generate the key request. - * @param mime Mime type. - */ - @CalledByNative - private void generateKeyRequest(byte[] initData, String mime) { - if (mSessionId == null) { - return; - } - try { - final byte[] session = mSessionId.getBytes("UTF-8"); - mMimeType = mime; - HashMap optionalParameters = new HashMap(); - final MediaDrm.KeyRequest request = mMediaDrm.getKeyRequest( - session, initData, mime, MediaDrm.KEY_TYPE_STREAMING, optionalParameters); - mhandler.post(new Runnable(){ - public void run() { - nativeOnKeyMessage(mNativeMediaDrmBridge, mSessionId, - request.getData(), request.getDefaultUrl()); - } - }); - return; - } catch (android.media.NotProvisionedException e) { - Log.e(TAG, "Cannot get key request " + e.toString()); - } catch (java.io.UnsupportedEncodingException e) { - Log.e(TAG, "Cannot get key request " + e.toString()); - } - onKeyError(); - } - - /** - * Cancel a key request for a session Id. - * - * @param sessionId Crypto session Id. - */ - @CalledByNative - private void cancelKeyRequest(String sessionId) { - if (mSessionId == null || !mSessionId.equals(sessionId)) { - return; - } - try { - final byte[] session = sessionId.getBytes("UTF-8"); - mMediaDrm.removeKeys(session); - } catch (java.io.UnsupportedEncodingException e) { - Log.e(TAG, "Cannot cancel key request " + e.toString()); - } - } - - /** - * Add a key for a session Id. - * - * @param sessionId Crypto session Id. - * @param key Response data from the server. - */ - @CalledByNative - private void addKey(String sessionId, byte[] key) { - if (mSessionId == null || !mSessionId.equals(sessionId)) { - return; - } - try { - final byte[] session = sessionId.getBytes("UTF-8"); - mMediaDrm.provideKeyResponse(session, key); - mhandler.post(new Runnable() { - public void run() { - nativeOnKeyAdded(mNativeMediaDrmBridge, mSessionId); - } - }); - return; - } catch (android.media.NotProvisionedException e) { - Log.e(TAG, "failed to provide key response " + e.toString()); - } catch (android.media.DeniedByServerException e) { - Log.e(TAG, "failed to provide key response " + e.toString()); - } catch (java.io.UnsupportedEncodingException e) { - Log.e(TAG, "failed to provide key response " + e.toString()); - } - onKeyError(); - } - - /** - * Called when the provision response is received. - * - * @param response Response data from the provision server. - */ - private void onProvisionResponse(byte[] response) { - try { - mMediaDrm.provideProvisionResponse(response); - } catch (android.media.DeniedByServerException e) { - Log.e(TAG, "failed to provide key response " + e.toString()); - } - } - - private void onKeyError() { - // TODO(qinmin): pass the error code to native. - mhandler.post(new Runnable() { - public void run() { - nativeOnKeyError(mNativeMediaDrmBridge, mSessionId); - } - }); - } - - private class MediaDrmListener implements MediaDrm.OnEventListener { - @Override - public void onEvent(MediaDrm mediaDrm, byte[] sessionId, int event, int extra, - byte[] data) { - switch(event) { - case MediaDrm.EVENT_PROVISION_REQUIRED: - MediaDrm.ProvisionRequest request = mMediaDrm.getProvisionRequest(); - PostRequestTask postTask = new PostRequestTask(request.getData()); - postTask.execute(request.getDefaultUrl()); - break; - case MediaDrm.EVENT_KEY_REQUIRED: - generateKeyRequest(data, mMimeType); - break; - case MediaDrm.EVENT_KEY_EXPIRED: - onKeyError(); - break; - case MediaDrm.EVENT_VENDOR_DEFINED: - assert(false); - break; - default: - Log.e(TAG, "Invalid DRM event " + (int)event); - return; - } - } - } - - private class PostRequestTask extends AsyncTask { - private static final String TAG = "PostRequestTask"; - - private byte[] mDrmRequest; - private byte[] mResponseBody; - - public PostRequestTask(byte[] drmRequest) { - mDrmRequest = drmRequest; - } - - @Override - protected Void doInBackground(String... urls) { - mResponseBody = postRequest(urls[0], mDrmRequest); - if (mResponseBody != null) { - Log.d(TAG, "response length=" + mResponseBody.length); - } - return null; - } - - private byte[] postRequest(String url, byte[] drmRequest) { - HttpClient httpClient = new DefaultHttpClient(); - HttpPost httpPost = new HttpPost(url + "&signedRequest=" + new String(drmRequest)); - - Log.d(TAG, "PostRequest:" + httpPost.getRequestLine()); - try { - // Add data - httpPost.setHeader("Accept", "*/*"); - httpPost.setHeader("User-Agent", "Widevine CDM v1.0"); - httpPost.setHeader("Content-Type", "application/json"); - - // Execute HTTP Post Request - HttpResponse response = httpClient.execute(httpPost); - - byte[] responseBody; - int responseCode = response.getStatusLine().getStatusCode(); - if (responseCode == 200) { - responseBody = EntityUtils.toByteArray(response.getEntity()); - } else { - Log.d(TAG, "Server returned HTTP error code " + responseCode); - return null; - } - return responseBody; - } catch (ClientProtocolException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - - @Override - protected void onPostExecute(Void v) { - onProvisionResponse(mResponseBody); - } - } - - private native void nativeOnKeyMessage(int nativeMediaDrmBridge, String sessionId, - byte[] message, String destinationUrl); - - private native void nativeOnKeyAdded(int nativeMediaDrmBridge, String sessionId); - - private native void nativeOnKeyError(int nativeMediaDrmBridge, String sessionId); -} diff --git a/chromium/media/base/android/java/src/org/chromium/media/VideoCapture.java b/chromium/media/base/android/java/src/org/chromium/media/VideoCapture.java index f055f35ed68..df9eb4dcffb 100644 --- a/chromium/media/base/android/java/src/org/chromium/media/VideoCapture.java +++ b/chromium/media/base/android/java/src/org/chromium/media/VideoCapture.java @@ -100,6 +100,12 @@ public class VideoCapture implements PreviewCallback, OnFrameAvailableListener { ", height=" + height + ", frameRate=" + frameRate); try { mCamera = Camera.open(mId); + } catch (RuntimeException ex) { + Log.e(TAG, "allocate:Camera.open: " + ex); + return false; + } + + try { Camera.CameraInfo camera_info = new Camera.CameraInfo(); Camera.getCameraInfo(mId, camera_info); mCameraOrientation = camera_info.orientation; @@ -113,7 +119,7 @@ public class VideoCapture implements PreviewCallback, OnFrameAvailableListener { // Calculate fps. List listFpsRange = parameters.getSupportedPreviewFpsRange(); - if (listFpsRange.size() == 0) { + if (listFpsRange == null || listFpsRange.size() == 0) { Log.e(TAG, "allocate: no fps range found"); return false; } diff --git a/chromium/media/base/android/media_codec_bridge.cc b/chromium/media/base/android/media_codec_bridge.cc index ab549367803..47ee5997160 100644 --- a/chromium/media/base/android/media_codec_bridge.cc +++ b/chromium/media/base/android/media_codec_bridge.cc @@ -94,9 +94,9 @@ void MediaCodecBridge::StartInternal() { GetOutputBuffers(); } -void MediaCodecBridge::Reset() { +int MediaCodecBridge::Reset() { JNIEnv* env = AttachCurrentThread(); - Java_MediaCodecBridge_flush(env, j_media_codec_.obj()); + return Java_MediaCodecBridge_flush(env, j_media_codec_.obj()); } void MediaCodecBridge::Stop() { @@ -297,18 +297,16 @@ bool AudioCodecBridge::ConfigureMediaFormat( } current_pos++; // The first header is identification header. - jobject identification_header = env->NewDirectByteBuffer( - const_cast(current_pos), header_length[0]); + ScopedJavaLocalRef first_header = + base::android::ToJavaByteArray(env, current_pos, header_length[0]); Java_MediaCodecBridge_setCodecSpecificData( - env, j_format, 0, identification_header); + env, j_format, 0, first_header.obj()); // The last header is codec header. - jobject codec_header = env->NewDirectByteBuffer( - const_cast(extra_data + total_length), - extra_data_size - total_length); + ScopedJavaLocalRef last_header = + base::android::ToJavaByteArray( + env, extra_data + total_length, extra_data_size - total_length); Java_MediaCodecBridge_setCodecSpecificData( - env, j_format, 1, codec_header); - env->DeleteLocalRef(codec_header); - env->DeleteLocalRef(identification_header); + env, j_format, 1, last_header.obj()); break; } case kCodecAAC: @@ -339,16 +337,18 @@ bool AudioCodecBridge::ConfigureMediaFormat( LOG(ERROR) << "Invalid AAC header"; return false; } - uint8 csd[2]; + const size_t kCsdLength = 2; + uint8 csd[kCsdLength]; csd[0] = profile << 3 | frequency_index >> 1; csd[1] = (frequency_index & 0x01) << 7 | channel_config << 3; - jobject header = env->NewDirectByteBuffer(csd, 2); + ScopedJavaLocalRef byte_array = + base::android::ToJavaByteArray(env, csd, kCsdLength); Java_MediaCodecBridge_setCodecSpecificData( - env, j_format, 0, header); + env, j_format, 0, byte_array.obj()); + // TODO(qinmin): pass an extra variable to this function to determine // whether we need to call this. Java_MediaCodecBridge_setFrameHasADTSHeader(env, j_format); - env->DeleteLocalRef(header); break; } default: diff --git a/chromium/media/base/android/media_codec_bridge.h b/chromium/media/base/android/media_codec_bridge.h index 3469b1804e7..a0edcb9e693 100644 --- a/chromium/media/base/android/media_codec_bridge.h +++ b/chromium/media/base/android/media_codec_bridge.h @@ -45,7 +45,9 @@ class MEDIA_EXPORT MediaCodecBridge { // DequeueInputBuffer() and DequeueOutputBuffer() become invalid. // Please note that this clears all the inputs in the media codec. In other // words, there will be no outputs until new input is provided. - void Reset(); + // Returns MEDIA_CODEC_ERROR if an unexpected error happens, or Media_CODEC_OK + // otherwise. + int Reset(); // Finishes the decode/encode session. The instance remains active // and ready to be StartAudio/Video()ed again. HOWEVER, due to the buggy diff --git a/chromium/media/base/android/media_drm_bridge.cc b/chromium/media/base/android/media_drm_bridge.cc index 9ac62ca6f48..ee4fbbdf115 100644 --- a/chromium/media/base/android/media_drm_bridge.cc +++ b/chromium/media/base/android/media_drm_bridge.cc @@ -4,15 +4,11 @@ #include "media/base/android/media_drm_bridge.h" -#include "base/android/build_info.h" #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/logging.h" -#include "jni/MediaDrmBridge_jni.h" #include "media/base/android/media_player_manager.h" -using base::android::AttachCurrentThread; -using base::android::ConvertUTF8ToJavaString; using base::android::ConvertJavaStringToUTF8; using base::android::JavaByteArrayToByteVector; using base::android::ScopedJavaLocalRef; @@ -139,83 +135,53 @@ static bool GetPsshData(const uint8* data, int data_size, } // static +bool MediaDrmBridge::IsAvailable() { + return false; +} + MediaDrmBridge* MediaDrmBridge::Create(int media_keys_id, - const std::vector& scheme_uuid, + const std::vector& uuid, MediaPlayerManager* manager) { - if (!IsAvailable() || scheme_uuid.empty()) + if (!IsAvailable()) return NULL; // TODO(qinmin): check whether the uuid is valid. - return new MediaDrmBridge(media_keys_id, scheme_uuid, manager); -} - -bool MediaDrmBridge::IsAvailable() { - return base::android::BuildInfo::GetInstance()->sdk_int() >= 18; -} - -bool MediaDrmBridge::RegisterMediaDrmBridge(JNIEnv* env) { - return RegisterNativesImpl(env); + return new MediaDrmBridge(media_keys_id, uuid, manager); } MediaDrmBridge::MediaDrmBridge(int media_keys_id, - const std::vector& scheme_uuid, + const std::vector& uuid, MediaPlayerManager* manager) - : media_keys_id_(media_keys_id), - scheme_uuid_(scheme_uuid), - manager_(manager) { - JNIEnv* env = AttachCurrentThread(); - CHECK(env); - - ScopedJavaLocalRef j_scheme_uuid = - base::android::ToJavaByteArray(env, &scheme_uuid[0], scheme_uuid.size()); - j_media_drm_.Reset(Java_MediaDrmBridge_create( - env, j_scheme_uuid.obj(), reinterpret_cast(this))); + : media_keys_id_(media_keys_id), uuid_(uuid), manager_(manager) { + // TODO(qinmin): pass the uuid to DRM engine. } -MediaDrmBridge::~MediaDrmBridge() { - JNIEnv* env = AttachCurrentThread(); - Java_MediaDrmBridge_release(env, j_media_drm_.obj()); -} +MediaDrmBridge::~MediaDrmBridge() {} bool MediaDrmBridge::GenerateKeyRequest(const std::string& type, const uint8* init_data, int init_data_length) { std::vector pssh_data; - if (!GetPsshData(init_data, init_data_length, scheme_uuid_, &pssh_data)) + if (!GetPsshData(init_data, init_data_length, uuid_, &pssh_data)) return false; - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef j_pssh_data = - base::android::ToJavaByteArray(env, &pssh_data[0], pssh_data.size()); - ScopedJavaLocalRef j_mime = ConvertUTF8ToJavaString(env, type); - Java_MediaDrmBridge_generateKeyRequest( - env, j_media_drm_.obj(), j_pssh_data.obj(), j_mime.obj()); - return true; + NOTIMPLEMENTED(); + return false; +} + +void MediaDrmBridge::CancelKeyRequest(const std::string& session_id) { + NOTIMPLEMENTED(); } void MediaDrmBridge::AddKey(const uint8* key, int key_length, const uint8* init_data, int init_data_length, const std::string& session_id) { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef j_key_data = - base::android::ToJavaByteArray(env, key, key_length); - ScopedJavaLocalRef j_session_id = - ConvertUTF8ToJavaString(env, session_id); - Java_MediaDrmBridge_addKey( - env, j_media_drm_.obj(), j_session_id.obj(), j_key_data.obj()); + NOTIMPLEMENTED(); } ScopedJavaLocalRef MediaDrmBridge::GetMediaCrypto() { - JNIEnv* env = AttachCurrentThread(); - return Java_MediaDrmBridge_getMediaCrypto(env, j_media_drm_.obj()); -} - -void MediaDrmBridge::CancelKeyRequest(const std::string& session_id) { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaLocalRef j_session_id = - ConvertUTF8ToJavaString(env, session_id); - Java_MediaDrmBridge_cancelKeyRequest( - env, j_media_drm_.obj(), j_session_id.obj()); + NOTIMPLEMENTED(); + return ScopedJavaLocalRef(); } void MediaDrmBridge::OnKeyMessage(JNIEnv* env, @@ -231,14 +197,13 @@ void MediaDrmBridge::OnKeyMessage(JNIEnv* env, manager_->OnKeyMessage(media_keys_id_, session_id, message, destination_url); } -void MediaDrmBridge::OnKeyAdded(JNIEnv* env, jobject, jstring j_session_id) { - std::string session_id = ConvertJavaStringToUTF8(env, j_session_id); - manager_->OnKeyAdded(media_keys_id_, session_id); -} - -void MediaDrmBridge::OnKeyError(JNIEnv* env, jobject, jstring j_session_id) { - std::string session_id = ConvertJavaStringToUTF8(env, j_session_id); - manager_->OnKeyError(media_keys_id_, session_id, MediaKeys::kUnknownError, 0); +void MediaDrmBridge::OnDrmEvent(JNIEnv* env, + jobject j_media_drm, + jstring session_id, + jint event, + jint extra, + jstring data) { + NOTIMPLEMENTED(); } } // namespace media diff --git a/chromium/media/base/android/media_drm_bridge.h b/chromium/media/base/android/media_drm_bridge.h index 26e64372684..42b67909ca7 100644 --- a/chromium/media/base/android/media_drm_bridge.h +++ b/chromium/media/base/android/media_drm_bridge.h @@ -23,17 +23,15 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys { public: virtual ~MediaDrmBridge(); - // Returns a MediaDrmBridge instance if |scheme_uuid| is supported, or a NULL + // Returns a MediaDrmBridge instance if |uuid| is supported, or a NULL // pointer otherwise. static MediaDrmBridge* Create(int media_keys_id, - const std::vector& scheme_uuid, + const std::vector& uuid, MediaPlayerManager* manager); - // Checks whether MediaDRM is available. + // Checks whether DRM is available. static bool IsAvailable(); - static bool RegisterMediaDrmBridge(JNIEnv* env); - // MediaKeys implementations. virtual bool GenerateKeyRequest(const std::string& type, const uint8* init_data, @@ -43,16 +41,14 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys { const std::string& session_id) OVERRIDE; virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; + // Drm related message was received. + void OnDrmEvent(JNIEnv* env, jobject, jstring session_id, + jint event, jint extra, jstring data); + // Called after we got the response for GenerateKeyRequest(). - void OnKeyMessage(JNIEnv* env, jobject, jstring j_session_id, + void OnKeyMessage(JNIEnv* env, jobject, jstring session_id, jbyteArray message, jstring destination_url); - // Called when key is added. - void OnKeyAdded(JNIEnv* env, jobject, jstring j_session_id); - - // Called when error happens. - void OnKeyError(JNIEnv* env, jobject, jstring j_session_id); - // Methods to create and release a MediaCrypto object. base::android::ScopedJavaLocalRef GetMediaCrypto(); @@ -60,17 +56,14 @@ class MEDIA_EXPORT MediaDrmBridge : public MediaKeys { private: MediaDrmBridge(int media_keys_id, - const std::vector& scheme_uuid, + const std::vector& uuid, MediaPlayerManager* manager); - // ID of the MediaKeys object. + // Id of the MediaKeys object. int media_keys_id_; // UUID of the key system. - std::vector scheme_uuid_; - - // Java MediaDrm instance. - base::android::ScopedJavaGlobalRef j_media_drm_; + std::vector uuid_; // Non-owned pointer. MediaPlayerManager* manager_; diff --git a/chromium/media/base/android/media_jni_registrar.cc b/chromium/media/base/android/media_jni_registrar.cc index b7d48ca0737..93a46c3b545 100644 --- a/chromium/media/base/android/media_jni_registrar.cc +++ b/chromium/media/base/android/media_jni_registrar.cc @@ -10,7 +10,6 @@ #include "media/audio/android/audio_manager_android.h" #include "media/base/android/media_codec_bridge.h" -#include "media/base/android/media_drm_bridge.h" #include "media/base/android/media_player_bridge.h" #include "media/base/android/media_player_listener.h" #include "media/base/android/webaudio_media_codec_bridge.h" @@ -23,8 +22,6 @@ static base::android::RegistrationMethod kMediaRegisteredMethods[] = { AudioManagerAndroid::RegisterAudioManager }, { "MediaCodecBridge", MediaCodecBridge::RegisterMediaCodecBridge }, - { "MediaDrmBridge", - MediaDrmBridge::RegisterMediaDrmBridge }, { "MediaPlayerBridge", MediaPlayerBridge::RegisterMediaPlayerBridge }, { "MediaPlayerListener", diff --git a/chromium/media/base/android/media_source_player.cc b/chromium/media/base/android/media_source_player.cc index 19dc446f2e8..3af8a2b0d3c 100644 --- a/chromium/media/base/android/media_source_player.cc +++ b/chromium/media/base/android/media_source_player.cc @@ -161,7 +161,12 @@ void MediaDecoderJob::DecodeInternal( if (needs_flush) { DVLOG(1) << "DecodeInternal needs flush."; input_eos_encountered_ = false; - media_codec_bridge_->Reset(); + int reset_status = media_codec_bridge_->Reset(); + if (0 != reset_status) { + ui_loop_->PostTask(FROM_HERE, base::Bind( + callback, DECODE_FAILED, start_presentation_timestamp, 0)); + return; + } } DecodeStatus decode_status = DECODE_INPUT_END_OF_STREAM; @@ -847,11 +852,11 @@ void MediaSourcePlayer::ConfigureVideoDecoderJob() { if (video_decoder_job_ && !reconfig_video_decoder_) return; - base::android::ScopedJavaLocalRef media_crypto; + base::android::ScopedJavaLocalRef media_codec; if (is_video_encrypted_) { if (drm_bridge_) { - media_crypto = drm_bridge_->GetMediaCrypto(); - DCHECK(!media_crypto.is_null()); + media_codec = drm_bridge_->GetMediaCrypto(); + DCHECK(!media_codec.is_null()); } else { LOG(INFO) << "MediaDrmBridge is not available when creating decoder " << "for encrypted video stream."; @@ -865,7 +870,7 @@ void MediaSourcePlayer::ConfigureVideoDecoderJob() { // Create the new VideoDecoderJob. video_decoder_job_.reset(VideoDecoderJob::Create( video_codec_, gfx::Size(width_, height_), surface_.j_surface().obj(), - media_crypto.obj())); + media_codec.obj())); if (video_decoder_job_) reconfig_video_decoder_ = false; diff --git a/chromium/media/base/run_all_unittests.cc b/chromium/media/base/run_all_unittests.cc index 4274634d0b7..28ef5c68f7a 100644 --- a/chromium/media/base/run_all_unittests.cc +++ b/chromium/media/base/run_all_unittests.cc @@ -11,6 +11,7 @@ #if defined(OS_ANDROID) #include "base/android/jni_android.h" #include "media/base/android/media_jni_registrar.h" +#include "ui/gl/android/gl_jni_registrar.h" #endif class TestSuiteNoAtExit : public base::TestSuite { @@ -28,6 +29,8 @@ void TestSuiteNoAtExit::Initialize() { #if defined(OS_ANDROID) // Register JNI bindings for android. JNIEnv* env = base::android::AttachCurrentThread(); + // Needed for surface texture support. + ui::gl::android::RegisterJni(env); media::RegisterJni(env); #endif diff --git a/chromium/media/ffmpeg/ffmpeg_regression_tests.cc b/chromium/media/ffmpeg/ffmpeg_regression_tests.cc index a780d432e98..19f00f81aef 100644 --- a/chromium/media/ffmpeg/ffmpeg_regression_tests.cc +++ b/chromium/media/ffmpeg/ffmpeg_regression_tests.cc @@ -359,7 +359,7 @@ FLAKY_FFMPEG_TEST_CASE(WEBM_2, "security/uninitialize.webm"); TEST_P(FFmpegRegressionTest, BasicPlayback) { if (GetParam().init_status == PIPELINE_OK) { ASSERT_TRUE(Start(GetTestDataFilePath(GetParam().filename), - GetParam().init_status, kHashed)); + GetParam().init_status, true)); Play(); ASSERT_EQ(WaitUntilEndedOrError(), GetParam().end_status); EXPECT_EQ(GetParam().video_md5, GetVideoHash()); @@ -374,7 +374,7 @@ TEST_P(FFmpegRegressionTest, BasicPlayback) { } } else { ASSERT_FALSE(Start(GetTestDataFilePath(GetParam().filename), - GetParam().init_status, kHashed)); + GetParam().init_status, true)); EXPECT_EQ(GetParam().video_md5, GetVideoHash()); EXPECT_EQ(GetParam().audio_md5, GetAudioHash()); } diff --git a/chromium/media/filters/ffmpeg_audio_decoder.cc b/chromium/media/filters/ffmpeg_audio_decoder.cc index 53dec642269..1c0cc58ecd9 100644 --- a/chromium/media/filters/ffmpeg_audio_decoder.cc +++ b/chromium/media/filters/ffmpeg_audio_decoder.cc @@ -354,6 +354,13 @@ bool FFmpegAudioDecoder::ConfigureDecoder() { // Store initial values to guard against midstream configuration changes. channels_ = codec_context_->channels; + if (channels_ != ChannelLayoutToChannelCount(channel_layout_)) { + DLOG(ERROR) << "Audio configuration specified " + << ChannelLayoutToChannelCount(channel_layout_) + << " channels, but FFmpeg thinks the file contains " + << channels_ << " channels"; + return false; + } av_sample_format_ = codec_context_->sample_fmt; sample_format_ = AVSampleFormatToSampleFormat( static_cast(av_sample_format_)); diff --git a/chromium/media/filters/gpu_video_accelerator_factories.cc b/chromium/media/filters/gpu_video_accelerator_factories.cc deleted file mode 100644 index f9f56604d25..00000000000 --- a/chromium/media/filters/gpu_video_accelerator_factories.cc +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/filters/gpu_video_accelerator_factories.h" - -namespace media { - -GpuVideoAcceleratorFactories::~GpuVideoAcceleratorFactories() {} - -} // namespace media diff --git a/chromium/media/filters/gpu_video_accelerator_factories.h b/chromium/media/filters/gpu_video_accelerator_factories.h deleted file mode 100644 index 3ee79ac6a5c..00000000000 --- a/chromium/media/filters/gpu_video_accelerator_factories.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ -#define MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ - -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "media/video/video_decode_accelerator.h" -#include "media/video/video_encode_accelerator.h" - -namespace base { -class MessageLoopProxy; -class SharedMemory; -} - -class SkBitmap; - -namespace media { - -// Helper interface for specifying factories needed to instantiate a hardware -// video accelerator. -class MEDIA_EXPORT GpuVideoAcceleratorFactories - : public base::RefCountedThreadSafe { - public: - // Caller owns returned pointer. - virtual scoped_ptr CreateVideoDecodeAccelerator( - VideoCodecProfile profile, - VideoDecodeAccelerator::Client* client) = 0; - - // Caller owns returned pointer. - virtual scoped_ptr CreateVideoEncodeAccelerator( - VideoEncodeAccelerator::Client* client) = 0; - - // Allocate & delete native textures. - virtual uint32 CreateTextures(int32 count, - const gfx::Size& size, - std::vector* texture_ids, - std::vector* texture_mailboxes, - uint32 texture_target) = 0; - virtual void DeleteTexture(uint32 texture_id) = 0; - - virtual void WaitSyncPoint(uint32 sync_point) = 0; - - // Read pixels from a native texture and store into |pixels| as RGBA. - virtual void ReadPixels(uint32 texture_id, - uint32 texture_target, - const gfx::Size& size, - const SkBitmap& pixels) = 0; - - // Allocate & return a shared memory segment. Caller is responsible for - // Close()ing the returned pointer. - virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0; - - // Returns the message loop the video accelerator runs on. - virtual scoped_refptr GetMessageLoop() = 0; - - // Abort any outstanding factory operations and error any future - // attempts at factory operations - virtual void Abort() = 0; - - // Returns true if Abort() has been called. - virtual bool IsAborted() = 0; - - protected: - friend class base::RefCountedThreadSafe; - virtual ~GpuVideoAcceleratorFactories(); -}; - -} // namespace media - -#endif // MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ diff --git a/chromium/media/filters/gpu_video_decoder.cc b/chromium/media/filters/gpu_video_decoder.cc index cecd55ec4da..30c6dfa94f5 100644 --- a/chromium/media/filters/gpu_video_decoder.cc +++ b/chromium/media/filters/gpu_video_decoder.cc @@ -17,7 +17,7 @@ #include "media/base/pipeline.h" #include "media/base/pipeline_status.h" #include "media/base/video_decoder_config.h" -#include "media/filters/gpu_video_accelerator_factories.h" +#include "media/filters/gpu_video_decoder_factories.h" namespace media { @@ -52,7 +52,7 @@ GpuVideoDecoder::BufferData::BufferData( GpuVideoDecoder::BufferData::~BufferData() {} GpuVideoDecoder::GpuVideoDecoder( - const scoped_refptr& factories) + const scoped_refptr& factories) : needs_bitstream_conversion_(false), gvd_loop_proxy_(factories->GetMessageLoop()), weak_factory_(this), @@ -173,8 +173,7 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, return; } - vda_ = - factories_->CreateVideoDecodeAccelerator(config.profile(), this).Pass(); + vda_.reset(factories_->CreateVideoDecodeAccelerator(config.profile(), this)); if (!vda_) { status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); return; @@ -436,7 +435,7 @@ void GpuVideoDecoder::PictureReady(const media::Picture& picture) { visible_rect, natural_size, timestamp, - base::Bind(&GpuVideoAcceleratorFactories::ReadPixels, + base::Bind(&GpuVideoDecoderFactories::ReadPixels, factories_, pb.texture_id(), decoder_texture_target_, diff --git a/chromium/media/filters/gpu_video_decoder.h b/chromium/media/filters/gpu_video_decoder.h index 2911e87c84e..29c330d2141 100644 --- a/chromium/media/filters/gpu_video_decoder.h +++ b/chromium/media/filters/gpu_video_decoder.h @@ -26,7 +26,7 @@ class SharedMemory; namespace media { class DecoderBuffer; -class GpuVideoAcceleratorFactories; +class GpuVideoDecoderFactories; // GPU-accelerated video decoder implementation. Relies on // AcceleratedVideoDecoderMsg_Decode and friends. @@ -36,7 +36,7 @@ class MEDIA_EXPORT GpuVideoDecoder public: // The message loop of |factories| will be saved to |gvd_loop_proxy_|. explicit GpuVideoDecoder( - const scoped_refptr& factories); + const scoped_refptr& factories); // VideoDecoder implementation. virtual void Initialize(const VideoDecoderConfig& config, @@ -117,7 +117,7 @@ class MEDIA_EXPORT GpuVideoDecoder base::WeakPtrFactory weak_factory_; base::WeakPtr weak_this_; - scoped_refptr factories_; + scoped_refptr factories_; // Populated during Initialize() (on success) and unchanged until an error // occurs. diff --git a/chromium/media/filters/gpu_video_decoder_factories.cc b/chromium/media/filters/gpu_video_decoder_factories.cc new file mode 100644 index 00000000000..67d24ce3773 --- /dev/null +++ b/chromium/media/filters/gpu_video_decoder_factories.cc @@ -0,0 +1,11 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/filters/gpu_video_decoder_factories.h" + +namespace media { + +GpuVideoDecoderFactories::~GpuVideoDecoderFactories() {} + +} // namespace media diff --git a/chromium/media/filters/gpu_video_decoder_factories.h b/chromium/media/filters/gpu_video_decoder_factories.h new file mode 100644 index 00000000000..107e2de8c3b --- /dev/null +++ b/chromium/media/filters/gpu_video_decoder_factories.h @@ -0,0 +1,67 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_FILTERS_GPU_VIDEO_DECODER_FACTORIES_H_ +#define MEDIA_FILTERS_GPU_VIDEO_DECODER_FACTORIES_H_ + +#include "base/memory/ref_counted.h" +#include "media/video/video_decode_accelerator.h" + +namespace base { +class MessageLoopProxy; +class SharedMemory; +} + +class SkBitmap; + +namespace media { + +// Helper interface for specifying factories needed to instantiate a hardware +// video decoder. +class MEDIA_EXPORT GpuVideoDecoderFactories + : public base::RefCountedThreadSafe { + public: + // Caller owns returned pointer. + virtual VideoDecodeAccelerator* CreateVideoDecodeAccelerator( + VideoCodecProfile profile, + VideoDecodeAccelerator::Client* client) = 0; + + // Allocate & delete native textures. + virtual uint32 CreateTextures(int32 count, + const gfx::Size& size, + std::vector* texture_ids, + std::vector* texture_mailboxes, + uint32 texture_target) = 0; + virtual void DeleteTexture(uint32 texture_id) = 0; + + virtual void WaitSyncPoint(uint32 sync_point) = 0; + + // Read pixels from a native texture and store into |pixels| as RGBA. + virtual void ReadPixels(uint32 texture_id, + uint32 texture_target, + const gfx::Size& size, + const SkBitmap& pixels) = 0; + + // Allocate & return a shared memory segment. Caller is responsible for + // Close()ing the returned pointer. + virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0; + + // Returns the message loop the VideoDecodeAccelerator runs on. + virtual scoped_refptr GetMessageLoop() = 0; + + // Abort any outstanding factory operations and error any future + // attempts at factory operations + virtual void Abort() = 0; + + // Returns true if Abort() has been called. + virtual bool IsAborted() = 0; + + protected: + friend class base::RefCountedThreadSafe; + virtual ~GpuVideoDecoderFactories(); +}; + +} // namespace media + +#endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_FACTORIES_H_ diff --git a/chromium/media/filters/mock_gpu_video_accelerator_factories.cc b/chromium/media/filters/mock_gpu_video_accelerator_factories.cc deleted file mode 100644 index f4f39973600..00000000000 --- a/chromium/media/filters/mock_gpu_video_accelerator_factories.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/filters/mock_gpu_video_accelerator_factories.h" - -namespace media { - -MockGpuVideoAcceleratorFactories::MockGpuVideoAcceleratorFactories() {} - -MockGpuVideoAcceleratorFactories::~MockGpuVideoAcceleratorFactories() {} - -scoped_ptr -MockGpuVideoAcceleratorFactories::CreateVideoDecodeAccelerator( - VideoCodecProfile profile, - VideoDecodeAccelerator::Client* client) { - return scoped_ptr( - DoCreateVideoDecodeAccelerator(profile, client)); -} - -scoped_ptr -MockGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator( - VideoEncodeAccelerator::Client* client) { - return scoped_ptr( - DoCreateVideoEncodeAccelerator(client)); -} - -} // namespace media diff --git a/chromium/media/filters/mock_gpu_video_accelerator_factories.h b/chromium/media/filters/mock_gpu_video_accelerator_factories.h deleted file mode 100644 index 8aa432d8cfc..00000000000 --- a/chromium/media/filters/mock_gpu_video_accelerator_factories.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_FILTERS_MOCK_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ -#define MEDIA_FILTERS_MOCK_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop_proxy.h" -#include "media/filters/gpu_video_accelerator_factories.h" -#include "media/video/video_decode_accelerator.h" -#include "media/video/video_encode_accelerator.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "third_party/skia/include/core/SkBitmap.h" - -template -class scoped_refptr; - -namespace base { -class SharedMemory; -} - -namespace media { - -class MockGpuVideoAcceleratorFactories : public GpuVideoAcceleratorFactories { - public: - MockGpuVideoAcceleratorFactories(); - - // CreateVideo{Decode,Encode}Accelerator returns scoped_ptr, which the mocking - // framework does not want. Trampoline them. - MOCK_METHOD2(DoCreateVideoDecodeAccelerator, - VideoDecodeAccelerator*(VideoCodecProfile, - VideoDecodeAccelerator::Client*)); - MOCK_METHOD1(DoCreateVideoEncodeAccelerator, - VideoEncodeAccelerator*(VideoEncodeAccelerator::Client*)); - - MOCK_METHOD5(CreateTextures, - uint32(int32 count, - const gfx::Size& size, - std::vector* texture_ids, - std::vector* texture_mailboxes, - uint32 texture_target)); - MOCK_METHOD1(DeleteTexture, void(uint32 texture_id)); - MOCK_METHOD1(WaitSyncPoint, void(uint32 sync_point)); - MOCK_METHOD4(ReadPixels, - void(uint32 texture_id, - uint32 texture_target, - const gfx::Size& size, - const SkBitmap& pixels)); - MOCK_METHOD1(CreateSharedMemory, base::SharedMemory*(size_t size)); - MOCK_METHOD0(GetMessageLoop, scoped_refptr()); - MOCK_METHOD0(Abort, void()); - MOCK_METHOD0(IsAborted, bool()); - - virtual scoped_ptr CreateVideoDecodeAccelerator( - VideoCodecProfile profile, - VideoDecodeAccelerator::Client* client) OVERRIDE; - - virtual scoped_ptr CreateVideoEncodeAccelerator( - VideoEncodeAccelerator::Client* client) OVERRIDE; - - private: - virtual ~MockGpuVideoAcceleratorFactories(); - - DISALLOW_COPY_AND_ASSIGN(MockGpuVideoAcceleratorFactories); -}; - -} // namespace media - -#endif // MEDIA_FILTERS_MOCK_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ diff --git a/chromium/media/filters/mock_gpu_video_decoder_factories.cc b/chromium/media/filters/mock_gpu_video_decoder_factories.cc new file mode 100644 index 00000000000..9a16a802c9d --- /dev/null +++ b/chromium/media/filters/mock_gpu_video_decoder_factories.cc @@ -0,0 +1,13 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/filters/mock_gpu_video_decoder_factories.h" + +namespace media { + +MockGpuVideoDecoderFactories::MockGpuVideoDecoderFactories() {} + +MockGpuVideoDecoderFactories::~MockGpuVideoDecoderFactories() {} + +} // namespace media diff --git a/chromium/media/filters/mock_gpu_video_decoder_factories.h b/chromium/media/filters/mock_gpu_video_decoder_factories.h new file mode 100644 index 00000000000..e0ad274b66f --- /dev/null +++ b/chromium/media/filters/mock_gpu_video_decoder_factories.h @@ -0,0 +1,55 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_FILTERS_MOCK_GPU_VIDEO_DECODER_FACTORIES_H_ +#define MEDIA_FILTERS_MOCK_GPU_VIDEO_DECODER_FACTORIES_H_ + +#include "base/message_loop/message_loop_proxy.h" +#include "media/filters/gpu_video_decoder_factories.h" +#include "media/video/video_decode_accelerator.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "third_party/skia/include/core/SkBitmap.h" + +template +class scoped_refptr; + +namespace base { +class SharedMemory; +} + +namespace media { + +class MockGpuVideoDecoderFactories : public GpuVideoDecoderFactories { + public: + MockGpuVideoDecoderFactories(); + MOCK_METHOD2(CreateVideoDecodeAccelerator, + VideoDecodeAccelerator*(VideoCodecProfile, + VideoDecodeAccelerator::Client*)); + MOCK_METHOD5(CreateTextures, + uint32(int32 count, + const gfx::Size& size, + std::vector* texture_ids, + std::vector* texture_mailboxes, + uint32 texture_target)); + MOCK_METHOD1(DeleteTexture, void(uint32 texture_id)); + MOCK_METHOD1(WaitSyncPoint, void(uint32 sync_point)); + MOCK_METHOD4(ReadPixels, + void(uint32 texture_id, + uint32 texture_target, + const gfx::Size& size, + const SkBitmap& pixels)); + MOCK_METHOD1(CreateSharedMemory, base::SharedMemory*(size_t size)); + MOCK_METHOD0(GetMessageLoop, scoped_refptr()); + MOCK_METHOD0(Abort, void()); + MOCK_METHOD0(IsAborted, bool()); + + private: + virtual ~MockGpuVideoDecoderFactories(); + + DISALLOW_COPY_AND_ASSIGN(MockGpuVideoDecoderFactories); +}; + +} // namespace media + +#endif // MEDIA_FILTERS_MOCK_GPU_VIDEO_DECODER_FACTORIES_H_ diff --git a/chromium/media/filters/pipeline_integration_test.cc b/chromium/media/filters/pipeline_integration_test.cc index 954fec0e9a8..26f65b96024 100644 --- a/chromium/media/filters/pipeline_integration_test.cc +++ b/chromium/media/filters/pipeline_integration_test.cc @@ -5,7 +5,6 @@ #include "media/filters/pipeline_integration_test_base.h" #include "base/bind.h" -#include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "build/build_config.h" @@ -59,9 +58,6 @@ static const int k1280IsoFileDurationMs = 2736; static const int kVP9WebMFileDurationMs = 2735; static const int kVP8AWebMFileDurationMs = 2700; -// Command line switch for runtime adjustment of audio file to be benchmarked. -static const char kBenchmarkAudioFile[] = "benchmark-audio-file"; - // Note: Tests using this class only exercise the DecryptingDemuxerStream path. // They do not exercise the Decrypting{Audio|Video}Decoder path. class FakeEncryptedMedia { @@ -407,8 +403,8 @@ TEST_F(PipelineIntegrationTest, BasicPlayback) { } TEST_F(PipelineIntegrationTest, BasicPlaybackHashed) { - ASSERT_TRUE(Start( - GetTestDataFilePath("bear-320x240.webm"), PIPELINE_OK, kHashed)); + ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240.webm"), + PIPELINE_OK, true)); Play(); @@ -418,31 +414,8 @@ TEST_F(PipelineIntegrationTest, BasicPlaybackHashed) { EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); } -TEST_F(PipelineIntegrationTest, AudioPlaybackBenchmark) { - // Audio-only files are all that is allowed for clockless playback. - // Audio file can be specified on the command line - // (--benchmark-audio-file=id3_png_test.mp3), so check for it. - std::string filename(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - kBenchmarkAudioFile)); - if (filename.empty()) - filename = "sfx_f32le.wav"; - - ASSERT_TRUE(Start(GetTestDataFilePath(filename), PIPELINE_OK, kClockless)); - - Play(); - - ASSERT_TRUE(WaitUntilOnEnded()); - - // Call Stop() to ensure that the rendering is complete. - Stop(); - printf("Clockless playback of %s took %.2f ms.\n", - filename.c_str(), - GetAudioTime().InMillisecondsF()); -} - TEST_F(PipelineIntegrationTest, F32PlaybackHashed) { - ASSERT_TRUE( - Start(GetTestDataFilePath("sfx_f32le.wav"), PIPELINE_OK, kHashed)); + ASSERT_TRUE(Start(GetTestDataFilePath("sfx_f32le.wav"), PIPELINE_OK, true)); Play(); ASSERT_TRUE(WaitUntilOnEnded()); EXPECT_EQ(std::string(kNullVideoHash), GetVideoHash()); diff --git a/chromium/media/filters/pipeline_integration_test_base.cc b/chromium/media/filters/pipeline_integration_test_base.cc index 31ae8ad827f..e2567adfbfe 100644 --- a/chromium/media/filters/pipeline_integration_test_base.cc +++ b/chromium/media/filters/pipeline_integration_test_base.cc @@ -26,7 +26,6 @@ const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; PipelineIntegrationTestBase::PipelineIntegrationTestBase() : hashing_enabled_(false), - clockless_playback_(false), pipeline_(new Pipeline(message_loop_.message_loop_proxy(), new MediaLog())), ended_(false), @@ -121,9 +120,8 @@ bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path, bool PipelineIntegrationTestBase::Start(const base::FilePath& file_path, PipelineStatus expected_status, - kTestType test_type) { - hashing_enabled_ = test_type == kHashed; - clockless_playback_ = test_type == kClockless; + bool hashing_enabled) { + hashing_enabled_ = hashing_enabled; return Start(file_path, expected_status); } @@ -231,32 +229,26 @@ PipelineIntegrationTestBase::CreateFilterCollection( scoped_ptr collection(new FilterCollection()); collection->SetDemuxer(demuxer_.get()); - if (!clockless_playback_) { - ScopedVector video_decoders; - video_decoders.push_back( - new VpxVideoDecoder(message_loop_.message_loop_proxy())); - video_decoders.push_back( - new FFmpegVideoDecoder(message_loop_.message_loop_proxy())); - - // Disable frame dropping if hashing is enabled. - scoped_ptr renderer(new VideoRendererBase( - message_loop_.message_loop_proxy(), - video_decoders.Pass(), - base::Bind(&PipelineIntegrationTestBase::SetDecryptor, - base::Unretained(this), - decryptor), - base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint, - base::Unretained(this)), - base::Bind(&PipelineIntegrationTestBase::OnSetOpaque, - base::Unretained(this)), - !hashing_enabled_)); - collection->SetVideoRenderer(renderer.Pass()); - - audio_sink_ = new NullAudioSink(message_loop_.message_loop_proxy()); - } else { - // audio only for clockless_playback_ - clockless_audio_sink_ = new ClocklessAudioSink(); - } + ScopedVector video_decoders; + video_decoders.push_back( + new VpxVideoDecoder(message_loop_.message_loop_proxy())); + video_decoders.push_back( + new FFmpegVideoDecoder(message_loop_.message_loop_proxy())); + + // Disable frame dropping if hashing is enabled. + scoped_ptr renderer(new VideoRendererBase( + message_loop_.message_loop_proxy(), + video_decoders.Pass(), + base::Bind(&PipelineIntegrationTestBase::SetDecryptor, + base::Unretained(this), decryptor), + base::Bind(&PipelineIntegrationTestBase::OnVideoRendererPaint, + base::Unretained(this)), + base::Bind(&PipelineIntegrationTestBase::OnSetOpaque, + base::Unretained(this)), + !hashing_enabled_)); + collection->SetVideoRenderer(renderer.Pass()); + + audio_sink_ = new NullAudioSink(message_loop_.message_loop_proxy()); ScopedVector audio_decoders; audio_decoders.push_back( @@ -266,9 +258,7 @@ PipelineIntegrationTestBase::CreateFilterCollection( AudioRendererImpl* audio_renderer_impl = new AudioRendererImpl( message_loop_.message_loop_proxy(), - (clockless_playback_) - ? static_cast(clockless_audio_sink_.get()) - : audio_sink_.get(), + audio_sink_.get(), audio_decoders.Pass(), base::Bind(&PipelineIntegrationTestBase::SetDecryptor, base::Unretained(this), @@ -311,9 +301,4 @@ std::string PipelineIntegrationTestBase::GetAudioHash() { return audio_sink_->GetAudioHashForTesting(); } -base::TimeDelta PipelineIntegrationTestBase::GetAudioTime() { - DCHECK(clockless_playback_); - return clockless_audio_sink_->render_time(); -} - } // namespace media diff --git a/chromium/media/filters/pipeline_integration_test_base.h b/chromium/media/filters/pipeline_integration_test_base.h index f91d8c4efea..e9dc0aa1bd1 100644 --- a/chromium/media/filters/pipeline_integration_test_base.h +++ b/chromium/media/filters/pipeline_integration_test_base.h @@ -7,7 +7,6 @@ #include "base/md5.h" #include "base/message_loop/message_loop.h" -#include "media/audio/clockless_audio_sink.h" #include "media/audio/null_audio_sink.h" #include "media/base/filter_collection.h" #include "media/base/media_keys.h" @@ -48,13 +47,10 @@ class PipelineIntegrationTestBase { bool WaitUntilOnEnded(); PipelineStatus WaitUntilEndedOrError(); bool Start(const base::FilePath& file_path, PipelineStatus expected_status); - // Enable playback with audio and video hashing enabled, or clockless - // playback (audio only). Frame dropping and audio underflow will be disabled - // if hashing enabled to ensure consistent hashes. - enum kTestType { kHashed, kClockless }; - bool Start(const base::FilePath& file_path, - PipelineStatus expected_status, - kTestType test_type); + // Enable playback with audio and video hashing enabled. Frame dropping and + // audio underflow will be disabled to ensure consistent hashes. + bool Start(const base::FilePath& file_path, PipelineStatus expected_status, + bool hashing_enabled); // Initialize the pipeline and ignore any status updates. Useful for testing // invalid audio/video clips which don't have deterministic results. bool Start(const base::FilePath& file_path); @@ -79,20 +75,14 @@ class PipelineIntegrationTestBase { // enabled. std::string GetAudioHash(); - // Returns the time taken to render the complete audio file. - // Pipeline must have been started with clockless playback enabled. - base::TimeDelta GetAudioTime(); - protected: base::MessageLoop message_loop_; base::MD5Context md5_context_; bool hashing_enabled_; - bool clockless_playback_; scoped_ptr demuxer_; scoped_ptr data_source_; scoped_ptr pipeline_; scoped_refptr audio_sink_; - scoped_refptr clockless_audio_sink_; bool ended_; PipelineStatus pipeline_status_; NeedKeyCB need_key_cb_; @@ -113,7 +103,6 @@ class PipelineIntegrationTestBase { void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); scoped_ptr CreateFilterCollection( scoped_ptr demuxer, Decryptor* decryptor); - void SetDecryptor(Decryptor* decryptor, const DecryptorReadyCB& decryptor_ready_cb); void OnVideoRendererPaint(const scoped_refptr& frame); diff --git a/chromium/media/filters/stream_parser_factory.cc b/chromium/media/filters/stream_parser_factory.cc index c883f967d9e..3038d3e737c 100644 --- a/chromium/media/filters/stream_parser_factory.cc +++ b/chromium/media/filters/stream_parser_factory.cc @@ -65,7 +65,11 @@ static const CodecInfo kVorbisCodecInfo = { "vorbis", CodecInfo::AUDIO, NULL, static const CodecInfo* kVideoWebMCodecs[] = { &kVP8CodecInfo, +#if !defined(OS_ANDROID) + // TODO(wonsik): crbug.com/285016 query Android platform for codec + // capabilities. &kVP9CodecInfo, +#endif &kVorbisCodecInfo, NULL }; diff --git a/chromium/media/media.gyp b/chromium/media/media.gyp index 92642a2173f..c685090fd17 100644 --- a/chromium/media/media.gyp +++ b/chromium/media/media.gyp @@ -99,8 +99,6 @@ 'audio/audio_source_diverter.h', 'audio/audio_util.cc', 'audio/audio_util.h', - 'audio/clockless_audio_sink.cc', - 'audio/clockless_audio_sink.h', 'audio/cras/audio_manager_cras.cc', 'audio/cras/audio_manager_cras.h', 'audio/cras/cras_input.cc', @@ -155,10 +153,10 @@ 'audio/openbsd/audio_manager_openbsd.h', 'audio/pulse/audio_manager_pulse.cc', 'audio/pulse/audio_manager_pulse.h', - 'audio/pulse/pulse_input.cc', - 'audio/pulse/pulse_input.h', 'audio/pulse/pulse_output.cc', 'audio/pulse/pulse_output.h', + 'audio/pulse/pulse_input.cc', + 'audio/pulse/pulse_input.h', 'audio/pulse/pulse_unified.cc', 'audio/pulse/pulse_unified.h', 'audio/pulse/pulse_util.cc', @@ -185,10 +183,10 @@ 'audio/win/audio_unified_win.h', 'audio/win/avrt_wrapper_win.cc', 'audio/win/avrt_wrapper_win.h', - 'audio/win/core_audio_util_win.cc', - 'audio/win/core_audio_util_win.h', 'audio/win/device_enumeration_win.cc', 'audio/win/device_enumeration_win.h', + 'audio/win/core_audio_util_win.cc', + 'audio/win/core_audio_util_win.h', 'audio/win/wavein_input_win.cc', 'audio/win/wavein_input_win.h', 'audio/win/waveout_output_win.cc', @@ -219,19 +217,19 @@ 'base/audio_pull_fifo.h', 'base/audio_renderer.cc', 'base/audio_renderer.h', + 'base/audio_renderer_sink.h', 'base/audio_renderer_mixer.cc', 'base/audio_renderer_mixer.h', 'base/audio_renderer_mixer_input.cc', 'base/audio_renderer_mixer_input.h', - 'base/audio_renderer_sink.h', 'base/audio_splicer.cc', 'base/audio_splicer.h', 'base/audio_timestamp_helper.cc', 'base/audio_timestamp_helper.h', 'base/bind_to_loop.h', + 'base/bitstream_buffer.h', 'base/bit_reader.cc', 'base/bit_reader.h', - 'base/bitstream_buffer.h', 'base/buffers.h', 'base/byte_queue.cc', 'base/byte_queue.h', @@ -249,10 +247,10 @@ 'base/decoder_buffer.h', 'base/decoder_buffer_queue.cc', 'base/decoder_buffer_queue.h', - 'base/decrypt_config.cc', - 'base/decrypt_config.h', 'base/decryptor.cc', 'base/decryptor.h', + 'base/decrypt_config.cc', + 'base/decrypt_config.h', 'base/demuxer.cc', 'base/demuxer.h', 'base/demuxer_stream.cc', @@ -350,10 +348,10 @@ 'filters/ffmpeg_video_decoder.h', 'filters/file_data_source.cc', 'filters/file_data_source.h', - 'filters/gpu_video_accelerator_factories.cc', - 'filters/gpu_video_accelerator_factories.h', 'filters/gpu_video_decoder.cc', 'filters/gpu_video_decoder.h', + 'filters/gpu_video_decoder_factories.cc', + 'filters/gpu_video_decoder_factories.h', 'filters/h264_to_annex_b_bitstream_converter.cc', 'filters/h264_to_annex_b_bitstream_converter.h', 'filters/in_memory_url_protocol.cc', @@ -374,12 +372,12 @@ 'filters/video_renderer_base.h', 'filters/vpx_video_decoder.cc', 'filters/vpx_video_decoder.h', - 'midi/midi_manager.cc', 'midi/midi_manager.h', - 'midi/midi_manager_mac.cc', + 'midi/midi_manager.cc', 'midi/midi_manager_mac.h', - 'midi/midi_port_info.cc', + 'midi/midi_manager_mac.cc', 'midi/midi_port_info.h', + 'midi/midi_port_info.cc', 'video/capture/android/video_capture_device_android.cc', 'video/capture/android/video_capture_device_android.h', 'video/capture/fake_video_capture_device.cc', @@ -418,8 +416,6 @@ 'video/picture.h', 'video/video_decode_accelerator.cc', 'video/video_decode_accelerator.h', - 'video/video_encode_accelerator.cc', - 'video/video_encode_accelerator.h', 'webm/webm_audio_client.cc', 'webm/webm_audio_client.h', 'webm/webm_cluster_parser.cc', @@ -1129,8 +1125,8 @@ 'base/mock_filters.h', 'base/test_helpers.cc', 'base/test_helpers.h', - 'filters/mock_gpu_video_accelerator_factories.cc', - 'filters/mock_gpu_video_accelerator_factories.h', + 'filters/mock_gpu_video_decoder_factories.cc', + 'filters/mock_gpu_video_decoder_factories.h', 'video/mock_video_decode_accelerator.cc', 'video/mock_video_decode_accelerator.h', ], @@ -1483,7 +1479,6 @@ 'sources': [ 'base/android/java/src/org/chromium/media/AudioManagerAndroid.java', 'base/android/java/src/org/chromium/media/MediaCodecBridge.java', - 'base/android/java/src/org/chromium/media/MediaDrmBridge.java', 'base/android/java/src/org/chromium/media/MediaPlayerBridge.java', 'base/android/java/src/org/chromium/media/MediaPlayerListener.java', 'base/android/java/src/org/chromium/media/WebAudioMediaCodecBridge.java', diff --git a/chromium/media/tools/shader_bench/shader_bench.cc b/chromium/media/tools/shader_bench/shader_bench.cc index 0b4236f1eb1..b26733ce032 100644 --- a/chromium/media/tools/shader_bench/shader_bench.cc +++ b/chromium/media/tools/shader_bench/shader_bench.cc @@ -13,7 +13,6 @@ #include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" #include "base/time/time.h" -#include "media/base/media.h" #include "media/base/video_frame.h" #include "media/tools/shader_bench/cpu_color_painter.h" #include "media/tools/shader_bench/gpu_color_painter.h" @@ -128,19 +127,18 @@ int main(int argc, char** argv) { // Initialize window and graphics context. base::AtExitManager at_exit_manager; - media::InitializeMediaLibraryForTesting(); gfx::GLSurface::InitializeOneOff(); scoped_ptr window(new media::Window(width, height)); - scoped_refptr surface = - gfx::GLSurface::CreateViewGLSurface(window->PluginWindow()); - scoped_refptr context = gfx::GLContext::CreateGLContext( - NULL, surface.get(), gfx::PreferDiscreteGpu); - context->MakeCurrent(surface.get()); + gfx::GLSurface* surface = + gfx::GLSurface::CreateViewGLSurface(window->PluginWindow()).get(); + gfx::GLContext* context = gfx::GLContext::CreateGLContext( + NULL, surface, gfx::PreferDiscreteGpu).get(); + context->MakeCurrent(surface); // This sets D3DPRESENT_INTERVAL_IMMEDIATE on Windows. context->SetSwapInterval(0); // Initialize and name GPU painters. - const struct { + static const struct { const char* name; GPUPainter* painter; } painters[] = { diff --git a/chromium/media/video/capture/win/filter_base_win.cc b/chromium/media/video/capture/win/filter_base_win.cc index ddc68d68b2c..89309df694d 100644 --- a/chromium/media/video/capture/win/filter_base_win.cc +++ b/chromium/media/video/capture/win/filter_base_win.cc @@ -72,6 +72,8 @@ class PinEnumerator STDMETHOD(Clone)(IEnumPins** clone) { PinEnumerator* pin_enum = new PinEnumerator(filter_); + if (!pin_enum) + return E_OUTOFMEMORY; pin_enum->AddRef(); pin_enum->index_ = index_; *clone = pin_enum; diff --git a/chromium/media/video/capture/win/pin_base_win.cc b/chromium/media/video/capture/win/pin_base_win.cc index e912b84ec2a..7e2f7b095ad 100644 --- a/chromium/media/video/capture/win/pin_base_win.cc +++ b/chromium/media/video/capture/win/pin_base_win.cc @@ -93,6 +93,8 @@ class TypeEnumerator STDMETHOD(Clone)(IEnumMediaTypes** clone) { TypeEnumerator* type_enum = new TypeEnumerator(pin_); + if (!type_enum) + return E_OUTOFMEMORY; type_enum->AddRef(); type_enum->index_ = index_; *clone = type_enum; diff --git a/chromium/media/video/video_encode_accelerator.cc b/chromium/media/video/video_encode_accelerator.cc deleted file mode 100644 index 6309180bceb..00000000000 --- a/chromium/media/video/video_encode_accelerator.cc +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/video/video_encode_accelerator.h" - -namespace media { - -VideoEncodeAccelerator::~VideoEncodeAccelerator() {} - -} // namespace media diff --git a/chromium/media/video/video_encode_accelerator.h b/chromium/media/video/video_encode_accelerator.h deleted file mode 100644 index 8d4f56536bf..00000000000 --- a/chromium/media/video/video_encode_accelerator.h +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ -#define MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ - -#include - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "media/base/bitstream_buffer.h" -#include "media/base/media_export.h" -#include "media/base/video_decoder_config.h" -#include "media/base/video_frame.h" - -namespace media { - -class BitstreamBuffer; -class VideoFrame; - -// Video encoder interface. -class MEDIA_EXPORT VideoEncodeAccelerator { - public: - virtual ~VideoEncodeAccelerator(); - - // Specification of an encoding profile supported by an encoder. - struct SupportedProfile { - VideoCodecProfile profile; - gfx::Size max_resolution; - struct { - uint32 numerator; - uint32 denominator; - } max_framerate; - }; - - // Enumeration of potential errors generated by the API. - enum Error { - // An operation was attempted during an incompatible encoder state. - kIllegalStateError, - // Invalid argument was passed to an API method. - kInvalidArgumentError, - // A failure occurred at the GPU process or one of its dependencies. - // Examples of such failures include GPU hardware failures, GPU driver - // failures, GPU library failures, GPU process programming errors, and so - // on. - kPlatformFailureError, - }; - - // Interface for clients that use VideoEncodeAccelerator. - class MEDIA_EXPORT Client { - public: - // Callback to notify client that encoder has been successfully initialized. - virtual void NotifyInitializeDone() = 0; - - // Callback to tell the client what size of frames and buffers to provide - // for input and output. The VEA disclaims use or ownership of all - // previously provided buffers once this callback is made. - // Parameters: - // |input_count| is the number of input VideoFrames required for encoding. - // The client should be prepared to feed at least this many frames into the - // encoder before being returned any input frames, since the encoder may - // need to hold onto some subset of inputs as reference pictures. - // |input_coded_size| is the logical size of the input frames (as reported - // by VideoFrame::coded_size()) to encode, in pixels. The encoder may have - // hardware alignment requirements that make this different from - // |input_visible_size|, as requested in Initialize(), in which case the - // input VideoFrame to Encode() should be padded appropriately. - // |output_buffer_size| is the required size of output buffers for this - // encoder in bytes. - virtual void RequireBitstreamBuffers(unsigned int input_count, - const gfx::Size& input_coded_size, - size_t output_buffer_size) = 0; - - // Callback to deliver encoded bitstream buffers. Ownership of the buffer - // is transferred back to the VEA::Client once this callback is made. - // Parameters: - // |bitstream_buffer_id| is the id of the buffer that is ready. - // |payload_size| is the byte size of the used portion of the buffer. - // |key_frame| is true if this delivered frame is a keyframe. - virtual void BitstreamBufferReady(int32 bitstream_buffer_id, - size_t payload_size, - bool key_frame) = 0; - - // Error notification callback. - virtual void NotifyError(Error error) = 0; - - protected: - // Clients are not owned by VEA instances and should not be deleted through - // these pointers. - virtual ~Client() {} - }; - - // Video encoder functions. - - // Initialize the video encoder with a specific configuration. Called once - // per encoder construction. - // Parameters: - // |input_format| is the frame format of the input stream (as would be - // reported by VideoFrame::format() for frames passed to Encode()). - // |input_visible_size| is the resolution of the input stream (as would be - // reported by VideoFrame::visible_rect().size() for frames passed to - // Encode()). - // |output_profile| is the codec profile of the encoded output stream. - // |initial_bitrate| is the initial bitrate of the encoded output stream, - // in bits per second. - // TODO(sheu): handle resolution changes. http://crbug.com/249944 - virtual void Initialize(media::VideoFrame::Format input_format, - const gfx::Size& input_visible_size, - VideoCodecProfile output_profile, - uint32 initial_bitrate) = 0; - - // Encodes the given frame. - // Parameters: - // |frame| is the VideoFrame that is to be encoded. - // |force_keyframe| forces the encoding of a keyframe for this frame. - virtual void Encode(const scoped_refptr& frame, - bool force_keyframe) = 0; - - // Send a bitstream buffer to the encoder to be used for storing future - // encoded output. Each call here with a given |buffer| will cause the buffer - // to be filled once, then returned with BitstreamBufferReady(). - // Parameters: - // |buffer| is the bitstream buffer to use for output. - virtual void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) = 0; - - // Request a change to the encoding parameters. This is only a request, - // fulfilled on a best-effort basis. - // Parameters: - // |bitrate| is the requested new bitrate, in bits per second. - // |framerate| is the requested new framerate, in frames per second. - virtual void RequestEncodingParametersChange(uint32 bitrate, - uint32 framerate) = 0; - - // Destroys the encoder: all pending inputs and outputs are dropped - // immediately and the component is freed. This call may asynchronously free - // system resources, but its client-visible effects are synchronous. After - // this method returns no more callbacks will be made on the client. Deletes - // |this| unconditionally, so make sure to drop all pointers to it! - virtual void Destroy() = 0; -}; - -} // namespace media - -#endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ diff --git a/chromium/media/webm/webm_cluster_parser.cc b/chromium/media/webm/webm_cluster_parser.cc index 9991d6b4d15..f83a3652f03 100644 --- a/chromium/media/webm/webm_cluster_parser.cc +++ b/chromium/media/webm/webm_cluster_parser.cc @@ -214,7 +214,7 @@ bool WebMClusterParser::ParseBlock(bool is_simple_block, const uint8* buf, // Sign extend negative timecode offsets. if (timecode & 0x8000) - timecode |= ~0xffff; + timecode |= (-1 << 16); const uint8* frame_data = buf + 4; int frame_size = size - (frame_data - buf); @@ -277,8 +277,6 @@ bool WebMClusterParser::OnBlock(bool is_simple_block, int track_num, return false; } - // TODO(acolwell): Should relative negative timecode offsets be rejected? Or - // only when the absolute timecode is negative? See http://crbug.com/271794 if (timecode < 0) { MEDIA_LOG(log_cb_) << "Got a block with negative timecode offset " << timecode; -- cgit v1.2.1