diff --git a/chrome/common/ppapi_utils.cc b/chrome/common/ppapi_utils.cc index b69436b5776455..e760aa599f917f 100644 --- a/chrome/common/ppapi_utils.cc +++ b/chrome/common/ppapi_utils.cc @@ -29,7 +29,6 @@ #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_buffer.h" #include "ppapi/c/ppb_audio_config.h" -#include "ppapi/c/ppb_audio_encoder.h" #include "ppapi/c/ppb_console.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_file_io.h" diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc index 681a0cd32a7c3a..fa4a67b6e10244 100644 --- a/chrome/test/ppapi/ppapi_browsertest.cc +++ b/chrome/test/ppapi/ppapi_browsertest.cc @@ -1960,11 +1960,6 @@ IN_PROC_BROWSER_TEST_F(PPAPINaClPNaClNonSfiTest, RUN_AUDIO_CONFIG_SUBTESTS; } -// Flaky on Windows https://crbug.com/1059468#c18 -#if !defined(OS_WIN) || !defined(ARCH_CPU_32_BITS) -TEST_PPAPI_NACL(AudioEncoder) -#endif - // PPB_Audio tests. #define RUN_AUDIO_SUBTESTS \ RunTestViaHTTP( \ diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn index 879925118243e5..ad84ab564f4e06 100644 --- a/content/renderer/BUILD.gn +++ b/content/renderer/BUILD.gn @@ -470,8 +470,6 @@ target(link_target_type, "renderer") { "pepper/message_channel.h", "pepper/pepper_audio_controller.cc", "pepper/pepper_audio_controller.h", - "pepper/pepper_audio_encoder_host.cc", - "pepper/pepper_audio_encoder_host.h", "pepper/pepper_audio_input_host.cc", "pepper/pepper_audio_input_host.h", "pepper/pepper_audio_output_host.cc", diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/content/renderer/pepper/content_renderer_pepper_host_factory.cc index 9648fe8ee4ccc2..824311c09265cb 100644 --- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc +++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc @@ -14,7 +14,6 @@ #include "content/common/content_switches_internal.h" #include "content/public/common/content_client.h" #include "content/public/renderer/content_renderer_client.h" -#include "content/renderer/pepper/pepper_audio_encoder_host.h" #include "content/renderer/pepper/pepper_audio_input_host.h" #include "content/renderer/pepper/pepper_audio_output_host.h" #include "content/renderer/pepper/pepper_camera_device_host.h" @@ -156,9 +155,6 @@ ContentRendererPepperHostFactory::CreateResourceHost( // Dev interfaces. if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { switch (message.type()) { - case PpapiHostMsg_AudioEncoder_Create::ID: - return std::make_unique(host_, instance, - resource); case PpapiHostMsg_AudioInput_Create::ID: return std::make_unique(host_, instance, resource); diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc index 9c1cd7c6c7939b..763d35fd7ea5b8 100644 --- a/content/renderer/pepper/plugin_module.cc +++ b/content/renderer/pepper/plugin_module.cc @@ -62,7 +62,6 @@ #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_buffer.h" #include "ppapi/c/ppb_audio_config.h" -#include "ppapi/c/ppb_audio_encoder.h" #include "ppapi/c/ppb_console.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_file_io.h" diff --git a/content/renderer/pepper/resource_creation_impl.cc b/content/renderer/pepper/resource_creation_impl.cc index c579dbfc48a872..81540f818e3465 100644 --- a/content/renderer/pepper/resource_creation_impl.cc +++ b/content/renderer/pepper/resource_creation_impl.cc @@ -64,10 +64,6 @@ PP_Resource ResourceCreationImpl::CreateAudioTrusted(PP_Instance instance) { return (new PPB_Audio_Impl(instance))->GetReference(); } -PP_Resource ResourceCreationImpl::CreateAudioEncoder(PP_Instance instance) { - return 0; // Not supported in-process. -} - PP_Resource ResourceCreationImpl::CreateAudioInput(PP_Instance instance) { return 0; // Not supported in-process. } diff --git a/content/renderer/pepper/resource_creation_impl.h b/content/renderer/pepper/resource_creation_impl.h index 5c112f40fdb292..af3ec62038dc79 100644 --- a/content/renderer/pepper/resource_creation_impl.h +++ b/content/renderer/pepper/resource_creation_impl.h @@ -33,7 +33,6 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI { PP_Resource config_id, PPB_Audio_Callback audio_callback, void* user_data) override; - PP_Resource CreateAudioEncoder(PP_Instance instance) override; PP_Resource CreateAudioTrusted(PP_Instance instance) override; PP_Resource CreateAudioConfig(PP_Instance instance, PP_AudioSampleRate sample_rate, diff --git a/native_client_sdk/src/libraries/ppapi/library.dsc b/native_client_sdk/src/libraries/ppapi/library.dsc index 0d62dec4d65d64..8ce5952d6c8099 100644 --- a/native_client_sdk/src/libraries/ppapi/library.dsc +++ b/native_client_sdk/src/libraries/ppapi/library.dsc @@ -21,7 +21,6 @@ 'pp_array_output.h', 'ppb_audio_buffer.h', 'ppb_audio_config.h', - 'ppb_audio_encoder.h', 'ppb_audio.h', 'ppb_console.h', 'ppb_core.h', diff --git a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc index 246df33f52e57f..3b9f42cb4b6b81 100644 --- a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc +++ b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc @@ -17,7 +17,6 @@ 'audio.cc', 'audio_buffer.cc', 'audio_config.cc', - 'audio_encoder.cc', 'core.cc', 'directory_entry.cc', 'file_io.cc', @@ -89,7 +88,6 @@ 'array_output.h', 'audio_buffer.h', 'audio_config.h', - 'audio_encoder.h', 'audio.h', 'completion_callback.h', 'core.h', diff --git a/ppapi/BUILD.gn b/ppapi/BUILD.gn index 75f980c921861c..bbd150845cd54a 100644 --- a/ppapi/BUILD.gn +++ b/ppapi/BUILD.gn @@ -32,8 +32,6 @@ test_common_source_files = [ "tests/test_audio.h", "tests/test_audio_config.cc", "tests/test_audio_config.h", - "tests/test_audio_encoder.cc", - "tests/test_audio_encoder.h", "tests/test_case.cc", "tests/test_case.h", "tests/test_console.cc", diff --git a/ppapi/api/pp_codecs.idl b/ppapi/api/pp_codecs.idl index 8699ec9853d9f9..0bdbf4d8b3ca8b 100644 --- a/ppapi/api/pp_codecs.idl +++ b/ppapi/api/pp_codecs.idl @@ -23,14 +23,6 @@ enum PP_VideoProfile { PP_VIDEOPROFILE_MAX = PP_VIDEOPROFILE_VP9_ANY }; -/** - * Audio profiles. - */ -enum PP_AudioProfile { - PP_AUDIOPROFILE_OPUS = 0, - PP_AUDIOPROFILE_MAX = PP_AUDIOPROFILE_OPUS -}; - /** * Hardware acceleration options. */ @@ -187,37 +179,6 @@ struct PP_VideoProfileDescription_0_1 { PP_HardwareAcceleration acceleration; }; -/** - * Supported audio profile information. See the PPB_AudioEncoder function - * GetSupportedProfiles() for more details. - */ -struct PP_AudioProfileDescription { - /** - * The codec profile. - */ - PP_AudioProfile profile; - - /** - * Maximum number of channels that can be encoded. - */ - uint32_t max_channels; - - /** - * Sample size. - */ - uint32_t sample_size; - - /** - * Sampling rate that can be encoded - */ - uint32_t sample_rate; - - /** - * Whether the profile is hardware accelerated. - */ - PP_Bool hardware_accelerated; -}; - /** * Struct describing a bitstream buffer. */ diff --git a/ppapi/api/ppb_audio_encoder.idl b/ppapi/api/ppb_audio_encoder.idl deleted file mode 100644 index 0a8029fcd386ed..00000000000000 --- a/ppapi/api/ppb_audio_encoder.idl +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright 2015 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. - */ - -/** - * This file defines the PPB_AudioEncoder interface. - */ - -[generate_thunk] - -label Chrome { - [channel=dev] M47 = 0.1 -}; - -/** - * Audio encoder interface. - * - * Typical usage: - * - Call Create() to create a new audio encoder resource. - * - Call GetSupportedProfiles() to determine which codecs and profiles are - * available. - * - Call Initialize() to initialize the encoder for a supported profile. - * - Call GetBuffer() to get an empty buffer and fill it in, or get an audio - * buffer from another resource, e.g. PPB_MediaStreamAudioTrack. - * - Call Encode() to push the audio buffer to the encoder. If an external - * buffer is pushed, wait for completion to recycle the buffer. - * - Call GetBitstreamBuffer() continuously (waiting for each previous call to - * complete) to pull encoded buffers from the encoder. - * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream - * buffer. - * - To destroy the encoder, the plugin should release all of its references to - * it. Any pending callbacks will abort before the encoder is destroyed. - * - * Available audio codecs vary by platform. - * All: opus. - */ -interface PPB_AudioEncoder { - /** - * Creates a new audio encoder resource. - * - * @param[in] instance A PP_Instance identifying the instance - * with the audio encoder. - * - * @return A PP_Resource corresponding to an audio encoder if - * successful or 0 otherwise. - */ - PP_Resource Create([in] PP_Instance instance); - - /** - * Determines if the given resource is an audio encoder. - * - * @param[in] resource A PP_Resource identifying a resource. - * - * @return PP_TRUE if the resource is a - * PPB_AudioEncoder, PP_FALSE if the resource is - * invalid or some other type. - */ - PP_Bool IsAudioEncoder([in] PP_Resource resource); - - /** - * Gets an array of supported audio encoder profiles. - * These can be used to choose a profile before calling Initialize(). - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] output A PP_ArrayOutput to receive the supported - * PP_AudioProfileDescription structs. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return If >= 0, the number of supported profiles returned, otherwise an - * error code from pp_errors.h. - */ - int32_t GetSupportedProfiles([in] PP_Resource audio_encoder, - [in] PP_ArrayOutput output, - [in] PP_CompletionCallback callback); - - /** - * Initializes an audio encoder resource. The plugin should call Initialize() - * successfully before calling any of the functions below. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] channels The number of audio channels to encode. - * @param[in] input_sampling_rate The sampling rate of the input audio buffer. - * @param[in] input_sample_size The sample size of the input audio buffer. - * @param[in] output_profile A PP_AudioProfile specifying the - * codec profile of the encoded output stream. - * @param[in] initial_bitrate The initial bitrate for the encoder. - * @param[in] acceleration A PP_HardwareAcceleration specifying - * whether to use a hardware accelerated or a software implementation. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the - * requested codec profile is not supported. - */ - int32_t Initialize([in] PP_Resource audio_encoder, - [in] uint32_t channels, - [in] PP_AudioBuffer_SampleRate input_sample_rate, - [in] PP_AudioBuffer_SampleSize input_sample_size, - [in] PP_AudioProfile output_profile, - [in] uint32_t initial_bitrate, - [in] PP_HardwareAcceleration acceleration, - [in] PP_CompletionCallback callback); - - /** - * Gets the number of audio samples per channel that audio buffers must - * contain in order to be processed by the encoder. This will be the number of - * samples per channels contained in buffers returned by GetBuffer(). - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @return An int32_t containing the number of samples required, or an error - * code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - */ - int32_t GetNumberOfSamples([in] PP_Resource audio_encoder); - - /** - * Gets a blank audio buffer (with metadata given by the Initialize() - * call) which can be filled with audio data and passed to the encoder. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[out] audio_buffer A blank PPB_AudioBuffer resource. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - */ - int32_t GetBuffer([in] PP_Resource audio_encoder, - [out] PP_Resource audio_buffer, - [in] PP_CompletionCallback callback); - - /** - * Encodes an audio buffer. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] audio_buffer The PPB_AudioBuffer to be encoded. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. Plugins that pass PPB_AudioBuffer resources owned - * by other resources should wait for completion before reusing them. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - */ - int32_t Encode([in] PP_Resource audio_encoder, - [in] PP_Resource audio_buffer, - [in] PP_CompletionCallback callback); - - /** - * Gets the next encoded bitstream buffer from the encoder. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[out] bitstream_buffer A PP_BitstreamBuffer containing - * encoded audio data. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. The plugin can call GetBitstreamBuffer from the callback in - * order to continuously "pull" bitstream buffers from the encoder. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has - * not completed. - */ - int32_t GetBitstreamBuffer([in] PP_Resource audio_encoder, - [out] PP_AudioBitstreamBuffer bitstream_buffer, - [in] PP_CompletionCallback callback); - - /** - * Recycles a bitstream buffer back to the encoder. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] bitstream_buffer A PP_BitstreamBuffer that is no - * longer needed by the plugin. - */ - void RecycleBitstreamBuffer([in] PP_Resource audio_encoder, - [in] PP_AudioBitstreamBuffer bitstream_buffer); - - /** - * Requests a change to the encoding bitrate. This is only a request, - * fulfilled on a best-effort basis. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] bitrate The requested new bitrate, in bits per second. - */ - void RequestBitrateChange([in] PP_Resource audio_encoder, - [in] uint32_t bitrate); - - /** - * Closes the audio encoder, and cancels any pending encodes. Any pending - * callbacks will still run, reporting PP_ERROR_ABORTED . It is - * not valid to call any encoder functions after a call to this method. - * Note: Destroying the audio encoder closes it implicitly, - * so you are not required to call Close(). - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - */ - void Close([in] PP_Resource audio_encoder); -}; diff --git a/ppapi/c/BUILD.gn b/ppapi/c/BUILD.gn index 443568a41af510..065dbfe8380ebe 100644 --- a/ppapi/c/BUILD.gn +++ b/ppapi/c/BUILD.gn @@ -29,7 +29,6 @@ source_set("c") { "ppb_audio.h", "ppb_audio_buffer.h", "ppb_audio_config.h", - "ppb_audio_encoder.h", "ppb_console.h", "ppb_core.h", "ppb_file_io.h", diff --git a/ppapi/c/pp_codecs.h b/ppapi/c/pp_codecs.h index 10d72d0d9020cd..000f6935e774f4 100644 --- a/ppapi/c/pp_codecs.h +++ b/ppapi/c/pp_codecs.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From pp_codecs.idl modified Fri Sep 18 10:42:55 2015. */ +/* From pp_codecs.idl modified Fri Mar 29 17:59:41 2019. */ #ifndef PPAPI_C_PP_CODECS_H_ #define PPAPI_C_PP_CODECS_H_ @@ -42,14 +42,6 @@ typedef enum { PP_VIDEOPROFILE_MAX = PP_VIDEOPROFILE_VP9_ANY } PP_VideoProfile; -/** - * Audio profiles. - */ -typedef enum { - PP_AUDIOPROFILE_OPUS = 0, - PP_AUDIOPROFILE_MAX = PP_AUDIOPROFILE_OPUS -} PP_AudioProfile; - /** * Hardware acceleration options. */ @@ -195,33 +187,6 @@ struct PP_VideoProfileDescription_0_1 { PP_HardwareAcceleration acceleration; }; -/** - * Supported audio profile information. See the PPB_AudioEncoder function - * GetSupportedProfiles() for more details. - */ -struct PP_AudioProfileDescription { - /** - * The codec profile. - */ - PP_AudioProfile profile; - /** - * Maximum number of channels that can be encoded. - */ - uint32_t max_channels; - /** - * Sample size. - */ - uint32_t sample_size; - /** - * Sampling rate that can be encoded - */ - uint32_t sample_rate; - /** - * Whether the profile is hardware accelerated. - */ - PP_Bool hardware_accelerated; -}; - /** * Struct describing a bitstream buffer. */ diff --git a/ppapi/c/ppb_audio_encoder.h b/ppapi/c/ppb_audio_encoder.h deleted file mode 100644 index 7fdac9039516c3..00000000000000 --- a/ppapi/c/ppb_audio_encoder.h +++ /dev/null @@ -1,222 +0,0 @@ -/* Copyright 2015 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. - */ - -/* From ppb_audio_encoder.idl modified Mon Sep 7 10:17:53 2015. */ - -#ifndef PPAPI_C_PPB_AUDIO_ENCODER_H_ -#define PPAPI_C_PPB_AUDIO_ENCODER_H_ - -#include "ppapi/c/pp_array_output.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_codecs.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/ppb_audio_buffer.h" - -#define PPB_AUDIOENCODER_INTERFACE_0_1 "PPB_AudioEncoder;0.1" /* dev */ -/** - * @file - * This file defines the PPB_AudioEncoder interface. - */ - - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * Audio encoder interface. - * - * Typical usage: - * - Call Create() to create a new audio encoder resource. - * - Call GetSupportedProfiles() to determine which codecs and profiles are - * available. - * - Call Initialize() to initialize the encoder for a supported profile. - * - Call GetBuffer() to get an empty buffer and fill it in, or get an audio - * buffer from another resource, e.g. PPB_MediaStreamAudioTrack. - * - Call Encode() to push the audio buffer to the encoder. If an external - * buffer is pushed, wait for completion to recycle the buffer. - * - Call GetBitstreamBuffer() continuously (waiting for each previous call to - * complete) to pull encoded buffers from the encoder. - * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream - * buffer. - * - To destroy the encoder, the plugin should release all of its references to - * it. Any pending callbacks will abort before the encoder is destroyed. - * - * Available audio codecs vary by platform. - * All: opus. - */ -struct PPB_AudioEncoder_0_1 { /* dev */ - /** - * Creates a new audio encoder resource. - * - * @param[in] instance A PP_Instance identifying the instance - * with the audio encoder. - * - * @return A PP_Resource corresponding to an audio encoder if - * successful or 0 otherwise. - */ - PP_Resource (*Create)(PP_Instance instance); - /** - * Determines if the given resource is an audio encoder. - * - * @param[in] resource A PP_Resource identifying a resource. - * - * @return PP_TRUE if the resource is a - * PPB_AudioEncoder, PP_FALSE if the resource is - * invalid or some other type. - */ - PP_Bool (*IsAudioEncoder)(PP_Resource resource); - /** - * Gets an array of supported audio encoder profiles. - * These can be used to choose a profile before calling Initialize(). - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] output A PP_ArrayOutput to receive the supported - * PP_AudioProfileDescription structs. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return If >= 0, the number of supported profiles returned, otherwise an - * error code from pp_errors.h. - */ - int32_t (*GetSupportedProfiles)(PP_Resource audio_encoder, - struct PP_ArrayOutput output, - struct PP_CompletionCallback callback); - /** - * Initializes an audio encoder resource. The plugin should call Initialize() - * successfully before calling any of the functions below. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] channels The number of audio channels to encode. - * @param[in] input_sampling_rate The sampling rate of the input audio buffer. - * @param[in] input_sample_size The sample size of the input audio buffer. - * @param[in] output_profile A PP_AudioProfile specifying the - * codec profile of the encoded output stream. - * @param[in] initial_bitrate The initial bitrate for the encoder. - * @param[in] acceleration A PP_HardwareAcceleration specifying - * whether to use a hardware accelerated or a software implementation. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the - * requested codec profile is not supported. - */ - int32_t (*Initialize)(PP_Resource audio_encoder, - uint32_t channels, - PP_AudioBuffer_SampleRate input_sample_rate, - PP_AudioBuffer_SampleSize input_sample_size, - PP_AudioProfile output_profile, - uint32_t initial_bitrate, - PP_HardwareAcceleration acceleration, - struct PP_CompletionCallback callback); - /** - * Gets the number of audio samples per channel that audio buffers must - * contain in order to be processed by the encoder. This will be the number of - * samples per channels contained in buffers returned by GetBuffer(). - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @return An int32_t containing the number of samples required, or an error - * code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - */ - int32_t (*GetNumberOfSamples)(PP_Resource audio_encoder); - /** - * Gets a blank audio buffer (with metadata given by the Initialize() - * call) which can be filled with audio data and passed to the encoder. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[out] audio_buffer A blank PPB_AudioBuffer resource. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - */ - int32_t (*GetBuffer)(PP_Resource audio_encoder, - PP_Resource* audio_buffer, - struct PP_CompletionCallback callback); - /** - * Encodes an audio buffer. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] audio_buffer The PPB_AudioBuffer to be encoded. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. Plugins that pass PPB_AudioBuffer resources owned - * by other resources should wait for completion before reusing them. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - */ - int32_t (*Encode)(PP_Resource audio_encoder, - PP_Resource audio_buffer, - struct PP_CompletionCallback callback); - /** - * Gets the next encoded bitstream buffer from the encoder. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[out] bitstream_buffer A PP_BitstreamBuffer containing - * encoded audio data. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. The plugin can call GetBitstreamBuffer from the callback in - * order to continuously "pull" bitstream buffers from the encoder. - * - * @return An int32_t containing an error code from pp_errors.h. - * Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has - * not completed. - */ - int32_t (*GetBitstreamBuffer)( - PP_Resource audio_encoder, - struct PP_AudioBitstreamBuffer* bitstream_buffer, - struct PP_CompletionCallback callback); - /** - * Recycles a bitstream buffer back to the encoder. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] bitstream_buffer A PP_BitstreamBuffer that is no - * longer needed by the plugin. - */ - void (*RecycleBitstreamBuffer)( - PP_Resource audio_encoder, - const struct PP_AudioBitstreamBuffer* bitstream_buffer); - /** - * Requests a change to the encoding bitrate. This is only a request, - * fulfilled on a best-effort basis. - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - * @param[in] bitrate The requested new bitrate, in bits per second. - */ - void (*RequestBitrateChange)(PP_Resource audio_encoder, uint32_t bitrate); - /** - * Closes the audio encoder, and cancels any pending encodes. Any pending - * callbacks will still run, reporting PP_ERROR_ABORTED . It is - * not valid to call any encoder functions after a call to this method. - * Note: Destroying the audio encoder closes it implicitly, - * so you are not required to call Close(). - * - * @param[in] audio_encoder A PP_Resource identifying the audio - * encoder. - */ - void (*Close)(PP_Resource audio_encoder); -}; -/** - * @} - */ - -#endif /* PPAPI_C_PPB_AUDIO_ENCODER_H_ */ - diff --git a/ppapi/cpp/BUILD.gn b/ppapi/cpp/BUILD.gn index bc805cc9b507e5..8dabad0b5b44a6 100644 --- a/ppapi/cpp/BUILD.gn +++ b/ppapi/cpp/BUILD.gn @@ -60,8 +60,6 @@ source_set("objects") { "audio_buffer.h", "audio_config.cc", "audio_config.h", - "audio_encoder.cc", - "audio_encoder.h", "completion_callback.h", "core.cc", "core.h", diff --git a/ppapi/cpp/audio_encoder.cc b/ppapi/cpp/audio_encoder.cc deleted file mode 100644 index bea733bb5b61b7..00000000000000 --- a/ppapi/cpp/audio_encoder.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2015 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 "ppapi/cpp/audio_encoder.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/ppb_audio_encoder.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> -const char* interface_name() { - return PPB_AUDIOENCODER_INTERFACE_0_1; -} - -} // namespace - -AudioEncoder::AudioEncoder() { -} - -AudioEncoder::AudioEncoder(const InstanceHandle& instance) { - if (has_interface()) { - PassRefFromConstructor( - get_interface()->Create(instance.pp_instance())); - } -} - -AudioEncoder::AudioEncoder(const AudioEncoder& other) : Resource(other) { -} - -int32_t AudioEncoder::GetSupportedProfiles(const CompletionCallbackWithOutput< - std::vector >& cc) { - if (has_interface()) { - return get_interface()->GetSupportedProfiles( - pp_resource(), cc.output(), cc.pp_completion_callback()); - } - return cc.MayForce(PP_ERROR_NOINTERFACE); -} - -int32_t AudioEncoder::Initialize(uint32_t channels, - PP_AudioBuffer_SampleRate input_sample_rate, - PP_AudioBuffer_SampleSize input_sample_size, - PP_AudioProfile output_profile, - uint32_t initial_bitrate, - PP_HardwareAcceleration acceleration, - const CompletionCallback& cc) { - if (has_interface()) { - return get_interface()->Initialize( - pp_resource(), channels, input_sample_rate, input_sample_size, - output_profile, initial_bitrate, acceleration, - cc.pp_completion_callback()); - } - return cc.MayForce(PP_ERROR_NOINTERFACE); -} - -int32_t AudioEncoder::GetNumberOfSamples() { - if (has_interface()) { - return get_interface()->GetNumberOfSamples( - pp_resource()); - } - return PP_ERROR_NOINTERFACE; -} - -int32_t AudioEncoder::GetBuffer( - const CompletionCallbackWithOutput& cc) { - if (has_interface()) { - return get_interface()->GetBuffer( - pp_resource(), cc.output(), cc.pp_completion_callback()); - } - return cc.MayForce(PP_ERROR_NOINTERFACE); -} - -int32_t AudioEncoder::Encode(const AudioBuffer& audio_buffer, - const CompletionCallback& cc) { - if (has_interface()) { - return get_interface()->Encode( - pp_resource(), audio_buffer.pp_resource(), cc.pp_completion_callback()); - } - return cc.MayForce(PP_ERROR_NOINTERFACE); -} - -int32_t AudioEncoder::GetBitstreamBuffer( - const CompletionCallbackWithOutput& cc) { - if (has_interface()) { - return get_interface()->GetBitstreamBuffer( - pp_resource(), cc.output(), cc.pp_completion_callback()); - } - return cc.MayForce(PP_ERROR_NOINTERFACE); -} - -void AudioEncoder::RecycleBitstreamBuffer( - const PP_AudioBitstreamBuffer& bitstream_buffer) { - if (has_interface()) { - get_interface()->RecycleBitstreamBuffer( - pp_resource(), &bitstream_buffer); - } -} - -void AudioEncoder::RequestBitrateChange(uint32_t bitrate) { - if (has_interface()) { - get_interface()->RequestBitrateChange(pp_resource(), - bitrate); - } -} - -void AudioEncoder::Close() { - if (has_interface()) - get_interface()->Close(pp_resource()); -} - -} // namespace pp diff --git a/ppapi/cpp/audio_encoder.h b/ppapi/cpp/audio_encoder.h deleted file mode 100644 index 9e5f3ea1d6244e..00000000000000 --- a/ppapi/cpp/audio_encoder.h +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2015 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 PPAPI_CPP_AUDIO_ENCODER_H_ -#define PPAPI_CPP_AUDIO_ENCODER_H_ - -#include - -#include "ppapi/c/pp_codecs.h" -#include "ppapi/c/ppb_audio_buffer.h" -#include "ppapi/cpp/audio_buffer.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/resource.h" - -/// @file -/// This file defines the API to create and use a AudioEncoder resource. - -namespace pp { - -class InstanceHandle; - -/// Audio encoder interface. -/// -/// Typical usage: -/// - Call Create() to create a new audio encoder resource. -/// - Call GetSupportedFormats() to determine which codecs and profiles are -/// available. -/// - Call Initialize() to initialize the encoder for a supported profile. -/// - Call GetBuffer() to get a blank frame and fill it in, or get an audio -/// frame from another resource, e.g. PPB_MediaStreamAudioTrack. -/// - Call Encode() to push the audio buffer to the encoder. If an external -/// buffer is pushed, wait for completion to recycle the frame. -/// - Call GetBitstreamBuffer() continuously (waiting for each previous call to -/// complete) to pull encoded buffers from the encoder. -/// - Call RecycleBitstreamBuffer() after consuming the data in the bitstream -/// buffer. -/// - To destroy the encoder, the plugin should release all of its references to -/// it. Any pending callbacks will abort before the encoder is destroyed. -/// -/// Available audio codecs vary by platform. -/// All: opus. -class AudioEncoder : public Resource { - public: - /// Default constructor for creating an is_null() AudioEncoder - /// object. - AudioEncoder(); - - /// A constructor used to create a AudioEncoder and associate it - /// with the provided Instance. - /// @param[in] instance The instance with which this resource will be - /// associated. - explicit AudioEncoder(const InstanceHandle& instance); - - /// The copy constructor for AudioEncoder. - /// @param[in] other A reference to a AudioEncoder. - AudioEncoder(const AudioEncoder& other); - - /// Gets an array of supported audio encoder profiles. - /// These can be used to choose a profile before calling Initialize(). - /// - /// @param[in] callback A CompletionCallbackWithOutput to be - /// called upon completion with the PP_AudioProfileDescription structs. - /// - /// @return If >= 0, the number of supported profiles returned, otherwise an - /// error code from pp_errors.h. - int32_t GetSupportedProfiles(const CompletionCallbackWithOutput< - std::vector >& cc); - - /// Initializes a audio encoder resource. This should be called after - /// GetSupportedProfiles() and before any functions below. - /// - /// @param[in] channels The number of audio channels to encode. - /// @param[in] input_sampling_rate The sampling rate of the input audio - /// buffer. - /// @param[in] input_sample_size The sample size of the input audio buffer. - /// @param[in] output_profile A PP_AudioProfile specifying the - /// codec profile of the encoded output stream. - /// @param[in] initial_bitrate The initial bitrate for the encoder. - /// @param[in] acceleration A PP_HardwareAcceleration specifying - /// whether to use a hardware accelerated or a software implementation. - /// @param[in] callback A CompletionCallback to be called upon - /// completion. - /// - /// @return An int32_t containing an error code from pp_errors.h. - /// Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the - /// requested codec profile is not supported. - /// Returns PP_ERROR_NOMEMORY if bitstream buffers can't be created. - int32_t Initialize(uint32_t channels, - PP_AudioBuffer_SampleRate input_sample_rate, - PP_AudioBuffer_SampleSize input_sample_size, - PP_AudioProfile output_profile, - uint32_t initial_bitrate, - PP_HardwareAcceleration acceleration, - const CompletionCallback& cc); - - /// Gets the number of audio samples per channel that audio buffers - /// must contain in order to be processed by the encoder. This will - /// be the number of samples per channels contained in buffers - /// returned by GetBuffer(). - /// - /// @return An int32_t containing the number of samples required, or an error - /// code from pp_errors.h. - /// Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - int32_t GetNumberOfSamples(); - - /// Gets a blank audio frame which can be filled with audio data and passed - /// to the encoder. - /// - /// @param[in] callback A CompletionCallbackWithOutput to be - /// called upon completion with the blank AudioBuffer resource. - /// - /// @return An int32_t containing an error code from pp_errors.h. - int32_t GetBuffer(const CompletionCallbackWithOutput& cc); - - /// Encodes an audio buffer. - /// - /// @param[in] audio_buffer The AudioBuffer to be encoded. - /// @param[in] callback A CompletionCallback to be called upon - /// completion. Plugins that pass AudioBuffer resources owned - /// by other resources should wait for completion before reusing them. - /// - /// @return An int32_t containing an error code from pp_errors.h. - /// Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - int32_t Encode(const AudioBuffer& buffer, const CompletionCallback& cc); - - /// Gets the next encoded bitstream buffer from the encoder. - /// - /// @param[in] callback A CompletionCallbackWithOutput to be - /// called upon completion with the next bitstream buffer. The plugin can call - /// GetBitstreamBuffer from the callback in order to continuously "pull" - /// bitstream buffers from the encoder. - /// - /// @return An int32_t containing an error code from pp_errors.h. - /// Returns PP_ERROR_FAILED if Initialize() has not successfully completed. - /// Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has - /// not completed. - int32_t GetBitstreamBuffer( - const CompletionCallbackWithOutput& cc); - - /// Recycles a bitstream buffer back to the encoder. - /// - /// @param[in] bitstream_buffer APP_AudioBitstreamBuffer that - /// is no longer needed by the plugin. - void RecycleBitstreamBuffer(const PP_AudioBitstreamBuffer& bitstream_buffer); - - /// Requests a change to the encoding bitrate. This is only a request, - /// fulfilled on a best-effort basis. - /// - /// @param[in] audio_encoder A PP_Resource identifying the audio - /// encoder. - void RequestBitrateChange(uint32_t bitrate); - - /// Closes the audio encoder, and cancels any pending encodes. Any pending - /// callbacks will still run, reporting PP_ERROR_ABORTED . It is - /// not valid to call any encoder functions after a call to this method. - /// Note: Destroying the audio encoder closes it implicitly, - /// so you are not required to call Close(). - void Close(); -}; - -} // namespace pp - -#endif // PPAPI_CPP_AUDIO_ENCODER_H_ diff --git a/ppapi/examples/audio_encode/audio_encode.cc b/ppapi/examples/audio_encode/audio_encode.cc deleted file mode 100644 index 947c9cafd27401..00000000000000 --- a/ppapi/examples/audio_encode/audio_encode.cc +++ /dev/null @@ -1,384 +0,0 @@ -// Copyright 2015 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 -#include -#include - -#include -#include -#include - -#include "ppapi/cpp/audio_buffer.h" -#include "ppapi/cpp/audio_encoder.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/logging.h" -#include "ppapi/cpp/media_stream_audio_track.h" -#include "ppapi/cpp/module.h" -#include "ppapi/cpp/var_array_buffer.h" -#include "ppapi/cpp/var_dictionary.h" -#include "ppapi/utility/completion_callback_factory.h" - -// When compiling natively on Windows, PostMessage can be #define-d to -// something else. -#ifdef PostMessage -#undef PostMessage -#endif - -// This example demonstrates receiving audio samples from an audio -// track and encoding them. - -namespace { - -class AudioEncoderInstance : public pp::Instance { - public: - explicit AudioEncoderInstance(PP_Instance instance); - virtual ~AudioEncoderInstance(); - - private: - // pp::Instance implementation. - virtual void HandleMessage(const pp::Var& var_message); - - std::string ProfileToString(PP_AudioProfile profile); - - void GetSupportedProfiles(); - void OnGetSupportedProfiles( - int32_t result, - const std::vector profiles); - - void StartAudioTrack(const pp::Resource& resource_track); - void StopAudioTrack(); - void OnGetBuffer(int32_t result, pp::AudioBuffer buffer); - - void InitializeEncoder(); - void OnEncoderInitialized(int32_t result); - void OnAudioTrackConfigured(int32_t result); - void GetEncoderBuffer(const pp::AudioBuffer& track_buffer); - void OnGetEncoderBuffer(int32_t result, - pp::AudioBuffer buffer, - pp::AudioBuffer track_buffer); - void OnEncodeDone(int32_t result); - void OnGetBitstreamBuffer(int32_t result, - const PP_AudioBitstreamBuffer& buffer); - - pp::VarDictionary NewCommand(const std::string& type); - - void Log(const std::string& message); - void LogError(int32_t error, const std::string& message); - - void PostAudioFormat(); - void PostDataMessage(const void* data, uint32_t size); - - pp::CompletionCallbackFactory callback_factory_; - - // Set when the plugin is not performing any encoding and just passing the - // uncompressed data directly to web page. - bool no_encoding_; - - uint32_t channels_; - uint32_t sample_rate_; - uint32_t sample_size_; - uint32_t samples_per_frame_; - - pp::MediaStreamAudioTrack audio_track_; - pp::AudioEncoder audio_encoder_; -}; - -AudioEncoderInstance::AudioEncoderInstance(PP_Instance instance) - : pp::Instance(instance), - callback_factory_(this), - no_encoding_(true), - channels_(0), - sample_rate_(0), - sample_size_(0), - samples_per_frame_(0), - audio_encoder_(this) { - GetSupportedProfiles(); -} - -AudioEncoderInstance::~AudioEncoderInstance() {} - -void AudioEncoderInstance::HandleMessage(const pp::Var& var_message) { - if (!var_message.is_dictionary()) { - LogError(PP_ERROR_FAILED, - "Cannot handle incoming message, not a dictionary"); - return; - } - - pp::VarDictionary dict_message(var_message); - std::string command = dict_message.Get("command").AsString(); - - if (command == "start") { - pp::Var var_track = dict_message.Get("track"); - if (!var_track.is_resource()) { - LogError(PP_ERROR_FAILED, "Given track is not a resource"); - return; - } - std::string profile = dict_message.Get("profile").AsString(); - if (profile == "wav") { - no_encoding_ = true; - } else { - no_encoding_ = false; - } - StartAudioTrack(var_track.AsResource()); - } else if (command == "stop") { - StopAudioTrack(); - } else { - LogError(PP_ERROR_FAILED, "Invalid command"); - } -} - -std::string AudioEncoderInstance::ProfileToString(PP_AudioProfile profile) { - if (profile == PP_AUDIOPROFILE_OPUS) - return "opus"; - return "unknown"; -} - -void AudioEncoderInstance::GetSupportedProfiles() { - audio_encoder_.GetSupportedProfiles(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetSupportedProfiles)); -} - -void AudioEncoderInstance::OnGetSupportedProfiles( - int32_t result, - const std::vector profiles) { - pp::VarDictionary dictionary = NewCommand("supportedProfiles"); - pp::VarArray js_profiles; - dictionary.Set(pp::Var("profiles"), js_profiles); - - if (result < 0) { - LogError(result, "Cannot get supported profiles"); - PostMessage(dictionary); - } - - int32_t idx = 0; - for (std::vector::const_iterator it = - profiles.begin(); - it != profiles.end(); ++it) { - pp::VarDictionary js_profile; - js_profile.Set(pp::Var("name"), pp::Var(ProfileToString(it->profile))); - js_profile.Set(pp::Var("sample_size"), - pp::Var(static_cast(it->sample_size))); - js_profile.Set(pp::Var("sample_rate"), - pp::Var(static_cast(it->sample_rate))); - js_profiles.Set(idx++, js_profile); - } - PostMessage(dictionary); -} - -void AudioEncoderInstance::StartAudioTrack(const pp::Resource& resource_track) { - audio_track_ = pp::MediaStreamAudioTrack(resource_track); - audio_track_.GetBuffer(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetBuffer)); -} - -void AudioEncoderInstance::StopAudioTrack() { - channels_ = 0; - audio_track_.Close(); - audio_track_ = pp::MediaStreamAudioTrack(); - audio_encoder_.Close(); - audio_encoder_ = pp::AudioEncoder(); -} - -void AudioEncoderInstance::OnGetBuffer(int32_t result, pp::AudioBuffer buffer) { - if (result == PP_ERROR_ABORTED) - return; - if (result != PP_OK) { - LogError(result, "Cannot get audio track buffer"); - return; - } - - // If this is the first buffer, then we need to initialize the encoder. - if (channels_ == 0) { - channels_ = buffer.GetNumberOfChannels(); - sample_rate_ = buffer.GetSampleRate(); - sample_size_ = buffer.GetSampleSize(); - samples_per_frame_ = buffer.GetNumberOfSamples(); - - if (no_encoding_) { - PostAudioFormat(); - PostDataMessage(buffer.GetDataBuffer(), buffer.GetDataBufferSize()); - audio_track_.GetBuffer(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetBuffer)); - } else { - InitializeEncoder(); - } - - // Given that once the encoder is initialized we might reconfigure the - // media track, we discard the first buffer to keep this example a bit - // simpler. - audio_track_.RecycleBuffer(buffer); - } else { - if (no_encoding_) { - PostDataMessage(buffer.GetDataBuffer(), buffer.GetDataBufferSize()); - audio_track_.RecycleBuffer(buffer); - } else { - GetEncoderBuffer(buffer); - } - - audio_track_.GetBuffer(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetBuffer)); - } -} - -void AudioEncoderInstance::InitializeEncoder() { - if (audio_encoder_.is_null()) - audio_encoder_ = pp::AudioEncoder(this); - audio_encoder_.Initialize( - channels_, static_cast(sample_rate_), - static_cast(sample_size_), - PP_AUDIOPROFILE_OPUS, 100000, PP_HARDWAREACCELERATION_WITHFALLBACK, - callback_factory_.NewCallback( - &AudioEncoderInstance::OnEncoderInitialized)); -} - -void AudioEncoderInstance::OnEncoderInitialized(int32_t result) { - if (result == PP_ERROR_ABORTED) - return; - if (result != PP_OK) { - LogError(result, "Cannot initialize encoder"); - return; - } - - int32_t attribs[] = { - // Duration in milliseconds. - PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, - 1000 / (sample_rate_ / audio_encoder_.GetNumberOfSamples()), - PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE}; - audio_track_.Configure(attribs, - callback_factory_.NewCallback( - &AudioEncoderInstance::OnAudioTrackConfigured)); - - samples_per_frame_ = audio_encoder_.GetNumberOfSamples(); - PostAudioFormat(); -} - -void AudioEncoderInstance::OnAudioTrackConfigured(int32_t result) { - if (result == PP_ERROR_ABORTED) - return; - if (result != PP_OK) { - LogError(result, "Cannot configure audio track buffer duration"); - return; - } - - audio_track_.GetBuffer(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetBuffer)); - audio_encoder_.GetBitstreamBuffer(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetBitstreamBuffer)); -} - -void AudioEncoderInstance::GetEncoderBuffer( - const pp::AudioBuffer& track_buffer) { - audio_encoder_.GetBuffer(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetEncoderBuffer, track_buffer)); -} - -void AudioEncoderInstance::OnGetEncoderBuffer(int32_t result, - pp::AudioBuffer buffer, - pp::AudioBuffer track_buffer) { - const char* error(nullptr); - - if (result != PP_OK) - error = "Cannot get encoder buffer"; - if (buffer.GetDataBufferSize() != track_buffer.GetDataBufferSize()) { - result = PP_ERROR_FAILED; - error = "Invalid buffer size"; - } - - if (result == PP_OK) { - memcpy(buffer.GetDataBuffer(), track_buffer.GetDataBuffer(), - buffer.GetDataBufferSize()); - audio_encoder_.Encode(buffer, callback_factory_.NewCallback( - &AudioEncoderInstance::OnEncodeDone)); - } else { - LogError(result, error); - StopAudioTrack(); - } - audio_track_.RecycleBuffer(track_buffer); -} - -void AudioEncoderInstance::OnEncodeDone(int32_t result) {} - -void AudioEncoderInstance::OnGetBitstreamBuffer( - int32_t result, - const PP_AudioBitstreamBuffer& buffer) { - if (result == PP_ERROR_ABORTED) - return; - if (result != PP_OK) { - LogError(result, "Cannot get bitstream buffer"); - return; - } - - audio_encoder_.GetBitstreamBuffer(callback_factory_.NewCallbackWithOutput( - &AudioEncoderInstance::OnGetBitstreamBuffer)); - - PostDataMessage(buffer.buffer, buffer.size); - audio_encoder_.RecycleBitstreamBuffer(buffer); -} - -pp::VarDictionary AudioEncoderInstance::NewCommand(const std::string& type) { - pp::VarDictionary dictionary; - dictionary.Set(pp::Var("command"), pp::Var(type)); - return dictionary; -} - -void AudioEncoderInstance::Log(const std::string& message) { - pp::VarDictionary dictionary = NewCommand("log"); - dictionary.Set(pp::Var("message"), pp::Var(message)); - PostMessage(dictionary); -} - -void AudioEncoderInstance::LogError(int32_t error, const std::string& message) { - pp::VarDictionary dictionary = NewCommand("error"); - std::string msg("Error: "); - msg.append(message); - msg.append(" : "); - msg.append(pp::Var(error).DebugString()); - dictionary.Set(pp::Var("message"), pp::Var(msg)); - PostMessage(dictionary); -} - -void AudioEncoderInstance::PostAudioFormat() { - pp::VarDictionary dictionary = NewCommand("format"); - dictionary.Set(pp::Var("channels"), pp::Var(static_cast(channels_))); - dictionary.Set(pp::Var("sample_rate"), - pp::Var(static_cast(sample_rate_))); - dictionary.Set(pp::Var("sample_size"), - pp::Var(static_cast(sample_size_))); - dictionary.Set(pp::Var("sample_per_frame"), - pp::Var(static_cast(samples_per_frame_))); - PostMessage(dictionary); -} - -void AudioEncoderInstance::PostDataMessage(const void* data, uint32_t size) { - pp::VarDictionary dictionary = NewCommand("data"); - uint8_t* buffer; - - pp::VarArrayBuffer array_buffer = pp::VarArrayBuffer(size); - buffer = static_cast(array_buffer.Map()); - memcpy(buffer, data, size); - array_buffer.Unmap(); - - dictionary.Set(pp::Var("buffer"), array_buffer); - - PostMessage(dictionary); -} - -class AudioEncoderModule : public pp::Module { - public: - virtual pp::Instance* CreateInstance(PP_Instance instance) { - return new AudioEncoderInstance(instance); - } -}; - -} // namespace - -namespace pp { - -// Factory function for your specialization of the Module object. -Module* CreateModule() { - return new AudioEncoderModule(); -} - -} // namespace pp diff --git a/ppapi/examples/audio_encode/audio_encode.html b/ppapi/examples/audio_encode/audio_encode.html deleted file mode 100644 index addeb1a238a01d..00000000000000 --- a/ppapi/examples/audio_encode/audio_encode.html +++ /dev/null @@ -1,418 +0,0 @@ - - - - - Audio Encoder Example - - - - -

Pepper Audio Encoder API Example


- This example demonstrates receiving frames from an audio MediaStreamTrack and - encoding them using AudioEncode.
- - - - -
-
-
- - - diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index c67f0374282f8c..430ee6ee064990 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -16,7 +16,6 @@ #include "ppapi/c/dev/ppb_url_util_dev.h" #include "ppapi/c/dev/ppb_video_capture_dev.h" #include "ppapi/c/dev/ppb_video_decoder_dev.h" -#include "ppapi/c/ppb_audio_encoder.h" #include "ppapi/c/ppb_console.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_file_io.h" @@ -81,7 +80,6 @@ static int mystrcmp(const char* s1, const char *s2) { /* BEGIN Declarations for all Wrapper Infos */ -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioEncoder_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Console_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Core_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_0; @@ -187,65 +185,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1; /* Not generating wrapper methods for PPB_AudioConfig_1_1 */ -/* Begin wrapper methods for PPB_AudioEncoder_0_1 */ - -static PP_Resource Pnacl_M47_PPB_AudioEncoder_Create(PP_Instance instance) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->Create(instance); -} - -static PP_Bool Pnacl_M47_PPB_AudioEncoder_IsAudioEncoder(PP_Resource resource) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->IsAudioEncoder(resource); -} - -static int32_t Pnacl_M47_PPB_AudioEncoder_GetSupportedProfiles(PP_Resource audio_encoder, struct PP_ArrayOutput* output, struct PP_CompletionCallback* callback) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->GetSupportedProfiles(audio_encoder, *output, *callback); -} - -static int32_t Pnacl_M47_PPB_AudioEncoder_Initialize(PP_Resource audio_encoder, uint32_t channels, PP_AudioBuffer_SampleRate input_sample_rate, PP_AudioBuffer_SampleSize input_sample_size, PP_AudioProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback* callback) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->Initialize(audio_encoder, channels, input_sample_rate, input_sample_size, output_profile, initial_bitrate, acceleration, *callback); -} - -static int32_t Pnacl_M47_PPB_AudioEncoder_GetNumberOfSamples(PP_Resource audio_encoder) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->GetNumberOfSamples(audio_encoder); -} - -static int32_t Pnacl_M47_PPB_AudioEncoder_GetBuffer(PP_Resource audio_encoder, PP_Resource* audio_buffer, struct PP_CompletionCallback* callback) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->GetBuffer(audio_encoder, audio_buffer, *callback); -} - -static int32_t Pnacl_M47_PPB_AudioEncoder_Encode(PP_Resource audio_encoder, PP_Resource audio_buffer, struct PP_CompletionCallback* callback) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->Encode(audio_encoder, audio_buffer, *callback); -} - -static int32_t Pnacl_M47_PPB_AudioEncoder_GetBitstreamBuffer(PP_Resource audio_encoder, struct PP_AudioBitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback* callback) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - return iface->GetBitstreamBuffer(audio_encoder, bitstream_buffer, *callback); -} - -static void Pnacl_M47_PPB_AudioEncoder_RecycleBitstreamBuffer(PP_Resource audio_encoder, const struct PP_AudioBitstreamBuffer* bitstream_buffer) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - iface->RecycleBitstreamBuffer(audio_encoder, bitstream_buffer); -} - -static void Pnacl_M47_PPB_AudioEncoder_RequestBitrateChange(PP_Resource audio_encoder, uint32_t bitrate) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - iface->RequestBitrateChange(audio_encoder, bitrate); -} - -static void Pnacl_M47_PPB_AudioEncoder_Close(PP_Resource audio_encoder) { - const struct PPB_AudioEncoder_0_1 *iface = Pnacl_WrapperInfo_PPB_AudioEncoder_0_1.real_iface; - iface->Close(audio_encoder); -} - -/* End wrapper methods for PPB_AudioEncoder_0_1 */ - /* Begin wrapper methods for PPB_Console_1_0 */ static void Pnacl_M25_PPB_Console_Log(PP_Instance instance, PP_LogLevel level, struct PP_Var* value) { @@ -3851,20 +3790,6 @@ static struct PP_Var Pnacl_M18_PPP_Instance_Private_GetInstanceObject(PP_Instanc /* Not generating wrapper interface for PPB_AudioConfig_1_1 */ -static const struct PPB_AudioEncoder_0_1 Pnacl_Wrappers_PPB_AudioEncoder_0_1 = { - .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M47_PPB_AudioEncoder_Create, - .IsAudioEncoder = (PP_Bool (*)(PP_Resource resource))&Pnacl_M47_PPB_AudioEncoder_IsAudioEncoder, - .GetSupportedProfiles = (int32_t (*)(PP_Resource audio_encoder, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M47_PPB_AudioEncoder_GetSupportedProfiles, - .Initialize = (int32_t (*)(PP_Resource audio_encoder, uint32_t channels, PP_AudioBuffer_SampleRate input_sample_rate, PP_AudioBuffer_SampleSize input_sample_size, PP_AudioProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback))&Pnacl_M47_PPB_AudioEncoder_Initialize, - .GetNumberOfSamples = (int32_t (*)(PP_Resource audio_encoder))&Pnacl_M47_PPB_AudioEncoder_GetNumberOfSamples, - .GetBuffer = (int32_t (*)(PP_Resource audio_encoder, PP_Resource* audio_buffer, struct PP_CompletionCallback callback))&Pnacl_M47_PPB_AudioEncoder_GetBuffer, - .Encode = (int32_t (*)(PP_Resource audio_encoder, PP_Resource audio_buffer, struct PP_CompletionCallback callback))&Pnacl_M47_PPB_AudioEncoder_Encode, - .GetBitstreamBuffer = (int32_t (*)(PP_Resource audio_encoder, struct PP_AudioBitstreamBuffer* bitstream_buffer, struct PP_CompletionCallback callback))&Pnacl_M47_PPB_AudioEncoder_GetBitstreamBuffer, - .RecycleBitstreamBuffer = (void (*)(PP_Resource audio_encoder, const struct PP_AudioBitstreamBuffer* bitstream_buffer))&Pnacl_M47_PPB_AudioEncoder_RecycleBitstreamBuffer, - .RequestBitrateChange = (void (*)(PP_Resource audio_encoder, uint32_t bitrate))&Pnacl_M47_PPB_AudioEncoder_RequestBitrateChange, - .Close = (void (*)(PP_Resource audio_encoder))&Pnacl_M47_PPB_AudioEncoder_Close -}; - static const struct PPB_Console_1_0 Pnacl_Wrappers_PPB_Console_1_0 = { .Log = (void (*)(PP_Instance instance, PP_LogLevel level, struct PP_Var value))&Pnacl_M25_PPB_Console_Log, .LogWithSource = (void (*)(PP_Instance instance, PP_LogLevel level, struct PP_Var source, struct PP_Var value))&Pnacl_M25_PPB_Console_LogWithSource @@ -4877,12 +4802,6 @@ static const struct PPP_Instance_Private_0_1 Pnacl_Wrappers_PPP_Instance_Private /* Not generating wrapper interface for PPP_PexeStreamHandler_1_0 */ -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioEncoder_0_1 = { - .iface_macro = PPB_AUDIOENCODER_INTERFACE_0_1, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_AudioEncoder_0_1, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Console_1_0 = { .iface_macro = PPB_CONSOLE_INTERFACE_1_0, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Console_1_0, @@ -5442,7 +5361,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1 = { }; static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { - &Pnacl_WrapperInfo_PPB_AudioEncoder_0_1, &Pnacl_WrapperInfo_PPB_Console_1_0, &Pnacl_WrapperInfo_PPB_Core_1_0, &Pnacl_WrapperInfo_PPB_FileIO_1_0, diff --git a/ppapi/proxy/BUILD.gn b/ppapi/proxy/BUILD.gn index b4aa521f4e9ef7..63c770bf4e641d 100644 --- a/ppapi/proxy/BUILD.gn +++ b/ppapi/proxy/BUILD.gn @@ -21,8 +21,6 @@ component("proxy") { "../utility/completion_callback_factory.h", "audio_buffer_resource.cc", "audio_buffer_resource.h", - "audio_encoder_resource.cc", - "audio_encoder_resource.h", "broker_resource.cc", "broker_resource.h", "camera_capabilities_resource.cc", diff --git a/ppapi/proxy/audio_encoder_resource.h b/ppapi/proxy/audio_encoder_resource.h deleted file mode 100644 index acdd774b973c76..00000000000000 --- a/ppapi/proxy/audio_encoder_resource.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2015 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 PPAPI_PROXY_AUDIO_ENCODER_RESOURCE_H_ -#define PPAPI_PROXY_AUDIO_ENCODER_RESOURCE_H_ - -#include - -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "ppapi/proxy/connection.h" -#include "ppapi/proxy/plugin_resource.h" -#include "ppapi/shared_impl/media_stream_buffer_manager.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_audio_encoder_api.h" - -namespace ppapi { - -class TrackedCallback; - -namespace proxy { - -class AudioBufferResource; - -class PPAPI_PROXY_EXPORT AudioEncoderResource - : public PluginResource, - public thunk::PPB_AudioEncoder_API, - public ppapi::MediaStreamBufferManager::Delegate { - public: - AudioEncoderResource(Connection connection, PP_Instance instance); - ~AudioEncoderResource() override; - - thunk::PPB_AudioEncoder_API* AsPPB_AudioEncoder_API() override; - - private: - // MediaStreamBufferManager::Delegate implementation. - void OnNewBufferEnqueued() override {} - - // PPB_AudioEncoder_API implementation. - int32_t GetSupportedProfiles( - const PP_ArrayOutput& output, - const scoped_refptr& callback) override; - int32_t Initialize(uint32_t channels, - PP_AudioBuffer_SampleRate input_sample_rate, - PP_AudioBuffer_SampleSize input_sample_size, - PP_AudioProfile output_profile, - uint32_t initial_bitrate, - PP_HardwareAcceleration acceleration, - const scoped_refptr& callback) override; - int32_t GetNumberOfSamples() override; - int32_t GetBuffer(PP_Resource* audio_buffer, - const scoped_refptr& callback) override; - int32_t Encode(PP_Resource audio_buffer, - const scoped_refptr& callback) override; - int32_t GetBitstreamBuffer( - PP_AudioBitstreamBuffer* bitstream_buffer, - const scoped_refptr& callback) override; - void RecycleBitstreamBuffer( - const PP_AudioBitstreamBuffer* bitstream_buffer) override; - void RequestBitrateChange(uint32_t bitrate) override; - void Close() override; - - // PluginResource implementation. - void OnReplyReceived(const ResourceMessageReplyParams& params, - const IPC::Message& msg) override; - - // Message handlers for the host's messages. - void OnPluginMsgGetSupportedProfilesReply( - const PP_ArrayOutput& output, - const ResourceMessageReplyParams& params, - const std::vector& profiles); - void OnPluginMsgInitializeReply(const ResourceMessageReplyParams& params, - int32_t number_of_samples, - int32_t audio_buffer_count, - int32_t audio_buffer_size, - int32_t bitstream_buffer_count, - int32_t bitstream_buffer_size); - void OnPluginMsgEncodeReply(const ResourceMessageReplyParams& params, - int32_t buffer_id); - void OnPluginMsgBitstreamBufferReady(const ResourceMessageReplyParams& params, - int32_t buffer_id); - void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params, - int32_t error); - - // Internal utility functions. - void NotifyError(int32_t error); - void TryGetAudioBuffer(); - void TryWriteBitstreamBuffer(); - void ReleaseBuffers(); - - int32_t encoder_last_error_; - - bool initialized_; - - uint32_t number_of_samples_; - - using AudioBufferMap = - std::map>; - AudioBufferMap audio_buffers_; - - scoped_refptr get_supported_profiles_callback_; - scoped_refptr initialize_callback_; - scoped_refptr get_buffer_callback_; - PP_Resource* get_buffer_data_; - - using EncodeMap = std::map>; - EncodeMap encode_callbacks_; - - scoped_refptr get_bitstream_buffer_callback_; - PP_AudioBitstreamBuffer* get_bitstream_buffer_data_; - - MediaStreamBufferManager audio_buffer_manager_; - MediaStreamBufferManager bitstream_buffer_manager_; - - // Map of bitstream buffer pointers to buffer ids. - using BufferMap = std::map; - BufferMap bitstream_buffer_map_; - - DISALLOW_COPY_AND_ASSIGN(AudioEncoderResource); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_AUDIO_ENCODER_RESOURCE_H_ diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 237ddc50e025ac..8a6c33a2147fe8 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -33,7 +33,6 @@ #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_buffer.h" #include "ppapi/c/ppb_audio_config.h" -#include "ppapi/c/ppb_audio_encoder.h" #include "ppapi/c/ppb_console.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_file_io.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index ec1b01ccb41cf0..43e9955b4944a8 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -135,7 +135,6 @@ IPC_ENUM_TRAITS_MIN_MAX_VALUE(PP_VideoDecoder_Profile, PP_VIDEODECODER_PROFILE_LAST) IPC_ENUM_TRAITS_MAX_VALUE(PP_VideoFrame_Format, PP_VIDEOFRAME_FORMAT_LAST) IPC_ENUM_TRAITS_MAX_VALUE(PP_HardwareAcceleration, PP_HARDWAREACCELERATION_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(PP_AudioProfile, PP_AUDIOPROFILE_MAX) IPC_ENUM_TRAITS_MAX_VALUE(PP_VideoProfile, PP_VIDEOPROFILE_MAX) IPC_ENUM_TRAITS_MAX_VALUE(PP_PrivateDirection, PP_PRIVATEDIRECTION_LAST) IPC_ENUM_TRAITS_MAX_VALUE(PP_TextRenderingMode, PP_TEXTRENDERINGMODE_LAST) @@ -582,14 +581,6 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::PpapiNaClPluginArgs) IPC_STRUCT_TRAITS_MEMBER(switch_values) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(PP_AudioProfileDescription) - IPC_STRUCT_TRAITS_MEMBER(profile) - IPC_STRUCT_TRAITS_MEMBER(max_channels) - IPC_STRUCT_TRAITS_MEMBER(sample_size) - IPC_STRUCT_TRAITS_MEMBER(sample_rate) - IPC_STRUCT_TRAITS_MEMBER(hardware_accelerated) -IPC_STRUCT_TRAITS_END() - IPC_STRUCT_TRAITS_BEGIN(PP_VideoProfileDescription) IPC_STRUCT_TRAITS_MEMBER(profile) IPC_STRUCT_TRAITS_MEMBER(max_resolution) @@ -598,15 +589,6 @@ IPC_STRUCT_TRAITS_MEMBER(max_framerate_denominator) IPC_STRUCT_TRAITS_MEMBER(hardware_accelerated) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::PPB_AudioEncodeParameters) - IPC_STRUCT_TRAITS_MEMBER(channels) - IPC_STRUCT_TRAITS_MEMBER(input_sample_rate) - IPC_STRUCT_TRAITS_MEMBER(input_sample_size) - IPC_STRUCT_TRAITS_MEMBER(output_profile) - IPC_STRUCT_TRAITS_MEMBER(initial_bitrate) - IPC_STRUCT_TRAITS_MEMBER(acceleration) -IPC_STRUCT_TRAITS_END() - // These are from the browser to the plugin. // Loads the given plugin. IPC_MESSAGE_CONTROL2(PpapiMsg_LoadPlugin, @@ -1073,32 +1055,6 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBAudio_StartOrStop, ppapi::HostResource /* audio_id */, bool /* play */) -// PPB_AudioEncoder -IPC_MESSAGE_CONTROL0(PpapiHostMsg_AudioEncoder_Create) -IPC_MESSAGE_CONTROL0(PpapiHostMsg_AudioEncoder_GetSupportedProfiles) -IPC_MESSAGE_CONTROL1(PpapiPluginMsg_AudioEncoder_GetSupportedProfilesReply, - std::vector /* results */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_AudioEncoder_Initialize, - ppapi::proxy::PPB_AudioEncodeParameters /* parameters */) -IPC_MESSAGE_CONTROL5(PpapiPluginMsg_AudioEncoder_InitializeReply, - int32_t /* number_of_samples */, - int32_t /* audio_buffer_count */, - int32_t /* audio_buffer_size */, - int32_t /* bitstream_buffer_count */, - int32_t /* bitstream_buffer_size */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_AudioEncoder_Encode, int32_t /* buffer_id */) -IPC_MESSAGE_CONTROL1(PpapiPluginMsg_AudioEncoder_EncodeReply, - int32_t /* buffer_id */) -IPC_MESSAGE_CONTROL1(PpapiPluginMsg_AudioEncoder_BitstreamBufferReady, - int32_t /* buffer_id */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_AudioEncoder_RecycleBitstreamBuffer, - int32_t /* buffer_id */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_AudioEncoder_RequestBitrateChange, - uint32_t /* bitrate */) -IPC_MESSAGE_CONTROL1(PpapiPluginMsg_AudioEncoder_NotifyError, - int32_t /* error */) -IPC_MESSAGE_CONTROL0(PpapiHostMsg_AudioEncoder_Close) - // PPB_Core. IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_AddRefResource, ppapi::HostResource) diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 33d478b8e34a15..584b715c2c2962 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -7,7 +7,6 @@ #include "build/build_config.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_size.h" -#include "ppapi/proxy/audio_encoder_resource.h" #include "ppapi/proxy/audio_input_resource.h" #include "ppapi/proxy/audio_output_resource.h" #include "ppapi/proxy/camera_device_resource.h" @@ -195,10 +194,6 @@ PP_Resource ResourceCreationProxy::CreateAudio( instance, config_id, AudioCallbackCombined(audio_callback), user_data); } -PP_Resource ResourceCreationProxy::CreateAudioEncoder(PP_Instance instance) { - return (new AudioEncoderResource(GetConnection(), instance))->GetReference(); -} - PP_Resource ResourceCreationProxy::CreateAudioTrusted(PP_Instance instance) { // Proxied plugins can't create trusted audio devices. return 0; diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 9994f3c8ab7523..06c02f79222ab0 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -99,7 +99,6 @@ class ResourceCreationProxy : public InterfaceProxy, PP_Resource config_id, PPB_Audio_Callback audio_callback, void* user_data) override; - PP_Resource CreateAudioEncoder(PP_Instance instance) override; PP_Resource CreateAudioTrusted(PP_Instance instance) override; PP_Resource CreateAudioConfig(PP_Instance instance, PP_AudioSampleRate sample_rate, diff --git a/ppapi/proxy/serialized_structs.h b/ppapi/proxy/serialized_structs.h index 52fdcdf5b92d7a..76e4fa5416ccb2 100644 --- a/ppapi/proxy/serialized_structs.h +++ b/ppapi/proxy/serialized_structs.h @@ -91,15 +91,6 @@ struct PPBURLLoader_UpdateProgress_Params { int64_t total_bytes_to_be_received; }; -struct PPB_AudioEncodeParameters { - uint32_t channels; - uint32_t input_sample_rate; - uint32_t input_sample_size; - PP_AudioProfile output_profile; - uint32_t initial_bitrate; - PP_HardwareAcceleration acceleration; -}; - } // namespace proxy } // namespace ppapi diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h index 0d9670d746a8ca..844da78f4b1a2d 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -22,7 +22,6 @@ F(PPB_Audio_API) \ F(PPB_AudioBuffer_API) \ F(PPB_AudioConfig_API) \ - F(PPB_AudioEncoder_API) \ F(PPB_AudioInput_API) \ F(PPB_AudioOutput_API) \ F(PPB_AudioTrusted_API) \ diff --git a/ppapi/tests/test_audio_encoder.cc b/ppapi/tests/test_audio_encoder.cc deleted file mode 100644 index cc629b5cdee07c..00000000000000 --- a/ppapi/tests/test_audio_encoder.cc +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2015 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 "ppapi/tests/test_audio_encoder.h" - -#include "ppapi/c/pp_codecs.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/audio_encoder.h" -#include "ppapi/tests/testing_instance.h" - -REGISTER_TEST_CASE(AudioEncoder); - -bool TestAudioEncoder::Init() { - audio_encoder_interface_ = static_cast( - pp::Module::Get()->GetBrowserInterface(PPB_AUDIOENCODER_INTERFACE_0_1)); - return audio_encoder_interface_ && CheckTestingInterface(); -} - -void TestAudioEncoder::RunTests(const std::string& filter) { - RUN_CALLBACK_TEST(TestAudioEncoder, AvailableCodecs, filter); - RUN_CALLBACK_TEST(TestAudioEncoder, IncorrectParametersFails, filter); - RUN_CALLBACK_TEST(TestAudioEncoder, InitializeTwiceFails, filter); - RUN_CALLBACK_TEST(TestAudioEncoder, InitializeOpusMono, filter); - RUN_CALLBACK_TEST(TestAudioEncoder, InitializeOpusStereo, filter); -} - -std::string TestAudioEncoder::TestAvailableCodecs() { - // Test that we get results for supported formats. We should at - // least get the software supported formats. - pp::AudioEncoder audio_encoder(instance_); - ASSERT_FALSE(audio_encoder.is_null()); - - TestCompletionCallbackWithOutput > - callback(instance_->pp_instance(), false); - callback.WaitForResult( - audio_encoder.GetSupportedProfiles(callback.GetCallback())); - ASSERT_GE(callback.result(), 1U); - - const std::vector audio_profiles = - callback.output(); - ASSERT_GE(audio_profiles.size(), 1U); - - bool found_opus_48hz = false; - for (uint32_t i = 0; i < audio_profiles.size(); ++i) { - const PP_AudioProfileDescription& description = audio_profiles[i]; - if (description.profile == PP_AUDIOPROFILE_OPUS && - description.sample_rate == PP_AUDIOBUFFER_SAMPLERATE_48000 && - description.max_channels >= 2) - found_opus_48hz = true; - } - ASSERT_TRUE(found_opus_48hz); - - PASS(); -} - -std::string TestAudioEncoder::TestIncorrectParametersFails() { - // Test that initializing the encoder with incorrect size fails. - pp::AudioEncoder audio_encoder(instance_); - ASSERT_FALSE(audio_encoder.is_null()); - - // Invalid number of channels. - TestCompletionCallback callback(instance_->pp_instance(), false); - callback.WaitForResult(audio_encoder.Initialize( - 42, PP_AUDIOBUFFER_SAMPLERATE_48000, PP_AUDIOBUFFER_SAMPLESIZE_16_BITS, - PP_AUDIOPROFILE_OPUS, 10000, PP_HARDWAREACCELERATION_WITHFALLBACK, - callback.GetCallback())); - ASSERT_EQ(PP_ERROR_NOTSUPPORTED, callback.result()); - - // Invalid sampling rate. - callback.WaitForResult(audio_encoder.Initialize( - 2, static_cast(123456), - PP_AUDIOBUFFER_SAMPLESIZE_16_BITS, PP_AUDIOPROFILE_OPUS, 10000, - PP_HARDWAREACCELERATION_WITHFALLBACK, callback.GetCallback())); - ASSERT_EQ(PP_ERROR_NOTSUPPORTED, callback.result()); - - // Invalid sample size. - callback.WaitForResult(audio_encoder.Initialize( - 2, static_cast(48000), - static_cast(72), PP_AUDIOPROFILE_OPUS, 10000, - PP_HARDWAREACCELERATION_WITHFALLBACK, callback.GetCallback())); - ASSERT_EQ(PP_ERROR_NOTSUPPORTED, callback.result()); - - PASS(); -} - -std::string TestAudioEncoder::TestInitializeTwiceFails() { - // Test that initializing the encoder with incorrect size fails. - pp::AudioEncoder audio_encoder(instance_); - ASSERT_FALSE(audio_encoder.is_null()); - - TestCompletionCallback callback(instance_->pp_instance(), false); - callback.WaitForResult(audio_encoder.Initialize( - 2, PP_AUDIOBUFFER_SAMPLERATE_48000, PP_AUDIOBUFFER_SAMPLESIZE_16_BITS, - PP_AUDIOPROFILE_OPUS, 10000, PP_HARDWAREACCELERATION_WITHFALLBACK, - callback.GetCallback())); - ASSERT_EQ(PP_OK, callback.result()); - - callback.WaitForResult(audio_encoder.Initialize( - 2, PP_AUDIOBUFFER_SAMPLERATE_48000, PP_AUDIOBUFFER_SAMPLESIZE_16_BITS, - PP_AUDIOPROFILE_OPUS, 10000, PP_HARDWAREACCELERATION_WITHFALLBACK, - callback.GetCallback())); - ASSERT_EQ(PP_ERROR_FAILED, callback.result()); - - PASS(); -} - -std::string TestAudioEncoder::TestInitializeOpusMono() { - return TestInitializeCodec(1, PP_AUDIOBUFFER_SAMPLERATE_48000, - PP_AUDIOBUFFER_SAMPLESIZE_16_BITS, - PP_AUDIOPROFILE_OPUS); -} - -std::string TestAudioEncoder::TestInitializeOpusStereo() { - return TestInitializeCodec(2, PP_AUDIOBUFFER_SAMPLERATE_48000, - PP_AUDIOBUFFER_SAMPLESIZE_16_BITS, - PP_AUDIOPROFILE_OPUS); -} - -std::string TestAudioEncoder::TestInitializeCodec( - uint32_t channels, - PP_AudioBuffer_SampleRate input_sample_rate, - PP_AudioBuffer_SampleSize input_sample_size, - PP_AudioProfile output_profile) { - pp::AudioEncoder audio_encoder(instance_); - ASSERT_FALSE(audio_encoder.is_null()); - pp::Size audio_size(640, 480); - - TestCompletionCallback callback(instance_->pp_instance(), false); - callback.WaitForResult(audio_encoder.Initialize( - channels, input_sample_rate, input_sample_size, output_profile, 10000, - PP_HARDWAREACCELERATION_WITHFALLBACK, callback.GetCallback())); - ASSERT_EQ(PP_OK, callback.result()); - - ASSERT_GE(audio_encoder.GetNumberOfSamples(), 2U); - - TestCompletionCallbackWithOutput get_buffer( - instance_->pp_instance(), false); - get_buffer.WaitForResult(audio_encoder.GetBuffer(get_buffer.GetCallback())); - ASSERT_EQ(PP_OK, get_buffer.result()); - - PASS(); -} diff --git a/ppapi/tests/test_audio_encoder.h b/ppapi/tests/test_audio_encoder.h deleted file mode 100644 index 2dd6f75f41bda1..00000000000000 --- a/ppapi/tests/test_audio_encoder.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 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 PPAPI_TESTS_TEST_AUDIO_ENCODER_H_ -#define PPAPI_TESTS_TEST_AUDIO_ENCODER_H_ - -#include - -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/ppb_audio_encoder.h" -#include "ppapi/tests/test_case.h" - -class TestAudioEncoder : public TestCase { - public: - explicit TestAudioEncoder(TestingInstance* instance) : TestCase(instance) {} - - private: - // TestCase implementation. - virtual bool Init(); - virtual void RunTests(const std::string& filter); - - std::string TestAvailableCodecs(); - std::string TestIncorrectParametersFails(); - std::string TestInitializeTwiceFails(); - std::string TestInitializeOpusMono(); - std::string TestInitializeOpusStereo(); - - std::string TestInitializeCodec(uint32_t channels, - PP_AudioBuffer_SampleRate input_sample_rate, - PP_AudioBuffer_SampleSize input_sample_size, - PP_AudioProfile output_profile); - - // Used by the tests that access the C API directly. - const PPB_AudioEncoder_0_1* audio_encoder_interface_; -}; - -#endif // PPAPI_TESTS_TEST_AUDIO_ENCODER_H_ diff --git a/ppapi/thunk/BUILD.gn b/ppapi/thunk/BUILD.gn index 2201f0f09bafae..4fcf79586966ae 100644 --- a/ppapi/thunk/BUILD.gn +++ b/ppapi/thunk/BUILD.gn @@ -28,8 +28,6 @@ source_set("thunk") { "ppb_audio_buffer_thunk.cc", "ppb_audio_config_api.h", "ppb_audio_config_thunk.cc", - "ppb_audio_encoder_api.h", - "ppb_audio_encoder_thunk.cc", "ppb_audio_input_api.h", "ppb_audio_output_api.h", "ppb_audio_thunk.cc", diff --git a/ppapi/thunk/interfaces_ppb_public_dev_channel.h b/ppapi/thunk/interfaces_ppb_public_dev_channel.h index 73c369841cc0ad..7fcc6748e2964f 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev_channel.h +++ b/ppapi/thunk/interfaces_ppb_public_dev_channel.h @@ -10,7 +10,6 @@ #include "ppapi/thunk/interfaces_preamble.h" // Interfaces go here. -PROXIED_IFACE(PPB_AUDIOENCODER_INTERFACE_0_1, PPB_AudioEncoder_0_1) PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_0_1, PPB_VideoDecoder_0_1) PROXIED_IFACE(PPB_VIDEOENCODER_INTERFACE_0_1, PPB_VideoEncoder_0_1) PROXIED_IFACE(PPB_VPNPROVIDER_INTERFACE_0_1, PPB_VpnProvider_0_1) diff --git a/ppapi/thunk/ppb_audio_encoder_api.h b/ppapi/thunk/ppb_audio_encoder_api.h deleted file mode 100644 index ee660fd88ba582..00000000000000 --- a/ppapi/thunk/ppb_audio_encoder_api.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2015 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 PPAPI_THUNK_AUDIO_ENCODER_API_H_ -#define PPAPI_THUNK_AUDIO_ENCODER_API_H_ - -#include - -#include "ppapi/c/ppb_audio_encoder.h" -#include "ppapi/thunk/ppapi_thunk_export.h" - -namespace ppapi { -namespace thunk { - -class PPAPI_THUNK_EXPORT PPB_AudioEncoder_API { - public: - virtual ~PPB_AudioEncoder_API() {} - - virtual int32_t GetSupportedProfiles( - const PP_ArrayOutput& output, - const scoped_refptr& callback) = 0; - virtual int32_t Initialize( - uint32_t channels, - PP_AudioBuffer_SampleRate input_sample_rate, - PP_AudioBuffer_SampleSize input_sample_size, - PP_AudioProfile output_profile, - uint32_t initial_bitrate, - PP_HardwareAcceleration acceleration, - const scoped_refptr& callback) = 0; - virtual int32_t GetNumberOfSamples() = 0; - virtual int32_t GetBuffer(PP_Resource* audio_buffer, - const scoped_refptr& callback) = 0; - virtual int32_t Encode(PP_Resource audio_buffer, - const scoped_refptr& callback) = 0; - virtual int32_t GetBitstreamBuffer( - PP_AudioBitstreamBuffer* bitstream_buffer, - const scoped_refptr& callback) = 0; - virtual void RecycleBitstreamBuffer( - const PP_AudioBitstreamBuffer* bitstream_buffer) = 0; - virtual void RequestBitrateChange(uint32_t bitrate) = 0; - virtual void Close() = 0; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_AUDIO_ENCODER_API_H_ diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 51228d5a673b52..90727f6ada32d7 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -122,7 +122,6 @@ class ResourceCreationAPI { PP_Resource config_id, PPB_Audio_Callback audio_callback, void* user_data) = 0; - virtual PP_Resource CreateAudioEncoder(PP_Instance instance) = 0; virtual PP_Resource CreateAudioTrusted(PP_Instance instance) = 0; virtual PP_Resource CreateAudioConfig(PP_Instance instance, PP_AudioSampleRate sample_rate, diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index d0a395002f17eb..83dbc9a3c04b1a 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -57143,7 +57143,7 @@ Called by update_net_trust_anchors.py.--> - +