1 /*
2  * Copyright (c) 2021-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef HISTREAMER_FILE_FD_SINK_PLUGIN_H
16 #define HISTREAMER_FILE_FD_SINK_PLUGIN_H
17 
18 #include "plugin/common/media_sink.h"
19 #include "plugin/interface/output_sink_plugin.h"
20 
21 namespace OHOS {
22 namespace Media {
23 namespace Plugin {
24 namespace FileSink {
25 class FileFdSinkPlugin : public OutputSinkPlugin {
26 public:
27     explicit FileFdSinkPlugin(std::string name);
28     ~FileFdSinkPlugin() override;
29     // file fd sink
30     Status SetSink(const MediaSink& sink) override;
31     Seekable GetSeekable()  override;
32     Status SeekTo(uint64_t offset)  override;
33     Status Write(const std::shared_ptr<Buffer>& buffer) override;
34     Status Flush() override;
35     Status Reset() override;
36     Status Stop() override;
37 private:
38     void CloseFd();
39     int32_t fd_ {-1};
40     Seekable seekable_;
41 };
42 }
43 }
44 }
45 }
46 #endif // HISTREAMER_FILE_FD_SINK_PLUGIN_H