| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 14 #include "base/numerics/safe_math.h" | 15 #include "base/numerics/safe_math.h" |
| 15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 16 #include "ppapi/c/pp_codecs.h" | 17 #include "ppapi/c/pp_codecs.h" |
| 17 #include "ppapi/host/host_message_context.h" | 18 #include "ppapi/host/host_message_context.h" |
| 18 #include "ppapi/host/resource_host.h" | 19 #include "ppapi/host/resource_host.h" |
| 19 #include "ppapi/proxy/resource_message_params.h" | 20 #include "ppapi/proxy/resource_message_params.h" |
| 20 #include "ppapi/proxy/serialized_structs.h" | 21 #include "ppapi/proxy/serialized_structs.h" |
| 21 #include "ppapi/shared_impl/media_stream_buffer_manager.h" | 22 #include "ppapi/shared_impl/media_stream_buffer_manager.h" |
| 22 | 23 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const ppapi::proxy::PPB_AudioEncodeParameters& parameters, | 65 const ppapi::proxy::PPB_AudioEncodeParameters& parameters, |
| 65 int32_t samples_per_frame); | 66 int32_t samples_per_frame); |
| 66 void DoEncode(); | 67 void DoEncode(); |
| 67 void BitstreamBufferReady(int32_t audio_buffer_id, | 68 void BitstreamBufferReady(int32_t audio_buffer_id, |
| 68 int32_t bitstream_buffer_id, | 69 int32_t bitstream_buffer_id, |
| 69 int32_t size); | 70 int32_t size); |
| 70 void NotifyPepperError(int32_t error); | 71 void NotifyPepperError(int32_t error); |
| 71 void Close(); | 72 void Close(); |
| 72 | 73 |
| 73 static void StopAudioEncoder( | 74 static void StopAudioEncoder( |
| 74 scoped_ptr<AudioEncoderImpl> encoder, | 75 std::unique_ptr<AudioEncoderImpl> encoder, |
| 75 scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager, | 76 std::unique_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager, |
| 76 scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager); | 77 std::unique_ptr<ppapi::MediaStreamBufferManager> |
| 78 bitstream_buffer_manager); |
| 77 | 79 |
| 78 // Non-owning pointer. | 80 // Non-owning pointer. |
| 79 RendererPpapiHost* renderer_ppapi_host_; | 81 RendererPpapiHost* renderer_ppapi_host_; |
| 80 | 82 |
| 81 // Whether the encoder has been successfully initialized. | 83 // Whether the encoder has been successfully initialized. |
| 82 bool initialized_; | 84 bool initialized_; |
| 83 | 85 |
| 84 // Last error reported by the encoder. | 86 // Last error reported by the encoder. |
| 85 // This represents the current error state of the encoder, i.e. PP_OK | 87 // This represents the current error state of the encoder, i.e. PP_OK |
| 86 // normally, or a Pepper error code if the encoder is uninitialized, | 88 // normally, or a Pepper error code if the encoder is uninitialized, |
| 87 // has been notified of an encoder error, has encountered some | 89 // has been notified of an encoder error, has encountered some |
| 88 // other unrecoverable error, or has been closed by the plugin. | 90 // other unrecoverable error, or has been closed by the plugin. |
| 89 // This field is checked in most message handlers to decide whether | 91 // This field is checked in most message handlers to decide whether |
| 90 // operations should proceed or fail. | 92 // operations should proceed or fail. |
| 91 int32_t encoder_last_error_; | 93 int32_t encoder_last_error_; |
| 92 | 94 |
| 93 // Manages buffers containing audio samples from the plugin. | 95 // Manages buffers containing audio samples from the plugin. |
| 94 scoped_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager_; | 96 std::unique_ptr<ppapi::MediaStreamBufferManager> audio_buffer_manager_; |
| 95 | 97 |
| 96 // Manages buffers containing encoded audio from the browser. | 98 // Manages buffers containing encoded audio from the browser. |
| 97 scoped_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager_; | 99 std::unique_ptr<ppapi::MediaStreamBufferManager> bitstream_buffer_manager_; |
| 98 | 100 |
| 99 // Media task runner used to run the encoder. | 101 // Media task runner used to run the encoder. |
| 100 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 102 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 101 | 103 |
| 102 // The encoder actually doing the work. | 104 // The encoder actually doing the work. |
| 103 scoped_ptr<AudioEncoderImpl> encoder_; | 105 std::unique_ptr<AudioEncoderImpl> encoder_; |
| 104 | 106 |
| 105 base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_; | 107 base::WeakPtrFactory<PepperAudioEncoderHost> weak_ptr_factory_; |
| 106 | 108 |
| 107 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost); | 109 DISALLOW_COPY_AND_ASSIGN(PepperAudioEncoderHost); |
| 108 }; | 110 }; |
| 109 | 111 |
| 110 } // namespace content | 112 } // namespace content |
| 111 | 113 |
| 112 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ | 114 #endif // CONTENT_RENDERER_PEPPER_PEPPER_AUDIO_ENCODER_HOST_H_ |
| OLD | NEW |