AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
FFmpegAttachmentInputController.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 #ifndef ALEXA_CLIENT_SDK_MEDIAPLAYER_ANDROIDSLESMEDIAPLAYER_INCLUDE_ANDROIDSLESMEDIAPLAYER_FFMPEGATTACHMENTINPUTCONTROLLER_H_
16 #define ALEXA_CLIENT_SDK_MEDIAPLAYER_ANDROIDSLESMEDIAPLAYER_INCLUDE_ANDROIDSLESMEDIAPLAYER_FFMPEGATTACHMENTINPUTCONTROLLER_H_
17 
18 #include <memory>
19 
22 
24 
25 struct AVIOContext;
26 struct AVInputFormat;
27 struct AVDictionary;
28 
29 namespace alexaClientSDK {
30 namespace mediaPlayer {
31 namespace android {
32 
39 public:
47  static std::unique_ptr<FFmpegAttachmentInputController> create(
48  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> reader,
49  const avsCommon::utils::AudioFormat* format = nullptr);
50 
53  bool hasNext() const override;
54  bool next() override;
55  std::tuple<Result, std::shared_ptr<AVFormatContext>, std::chrono::milliseconds> getCurrentFormatContext() override;
57 
62 
63 private:
72  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> reader,
73  std::shared_ptr<AVInputFormat> inputFormat = nullptr,
74  std::shared_ptr<AVDictionary> inputOptions = nullptr);
75 
83  int read(uint8_t* buffer, int bufferSize);
84 
93  static int feedBuffer(void* userData, uint8_t* buffer, int bufferSize);
94 
95  /*
96  * Whether the data input has encountered EOF. This is needed in order to know whether to ignore
97  * ffmpeg errors when ffmpeg probes the header for format; sometimes the entire attachment is empty,
98  * so ffmpeg cannot determine the format.
99  */
100  bool m_reachedEOF;
101 
103  std::shared_ptr<avsCommon::avs::attachment::AttachmentReader> m_reader;
104 
106  std::shared_ptr<AVInputFormat> m_inputFormat;
107 
109  std::shared_ptr<AVDictionary> m_inputOptions;
110 
112  std::shared_ptr<AVIOContext> m_ioContext;
113 };
114 
115 } // namespace android
116 } // namespace mediaPlayer
117 } // namespace alexaClientSDK
118 
119 #endif // ALEXA_CLIENT_SDK_MEDIAPLAYER_ANDROIDSLESMEDIAPLAYER_INCLUDE_ANDROIDSLESMEDIAPLAYER_FFMPEGATTACHMENTINPUTCONTROLLER_H_
Definition: FFmpegInputControllerInterface.h:37
static std::unique_ptr< FFmpegAttachmentInputController > create(std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > reader, const avsCommon::utils::AudioFormat *format=nullptr)
Definition: FFmpegAttachmentInputController.h:38
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::tuple< Result, std::shared_ptr< AVFormatContext >, std::chrono::milliseconds > getCurrentFormatContext() override

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0