• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PATH_SINK_PLUGIN_H
16 #define HISTREAMER_FILE_PATH_SINK_PLUGIN_H
17 
18 #include <cstdio>
19 #include "plugin/common/media_sink.h"
20 #include "plugin/interface/output_sink_plugin.h"
21 
22 namespace OHOS {
23 namespace Media {
24 namespace Plugin {
25 namespace FileSink {
26 class FilePathSinkPlugin : public OutputSinkPlugin {
27 public:
28     explicit FilePathSinkPlugin(std::string name);
29     ~FilePathSinkPlugin() override;
30 
31     Status Stop() override;
32 
33     // file path sink
34     Status SetSink(const MediaSink& sink) override;
35     Seekable GetSeekable()  override;
36     Status SeekTo(uint64_t offset)  override;
37     Status Write(const std::shared_ptr<Buffer>& buffer) override;
38     Status Flush() override;
39     Status Reset() override;
40 private:
41     Status OpenFile();
42     void CloseFile();
43 
44     std::string fileName_ {};
45     std::string tmpFileName_ {};
46     std::FILE* fp_;
47     Seekable seekable_;
48 };
49 }
50 }
51 }
52 }
53 #endif // HISTREAMER_FILE_PATH_SINK_PLUGIN_H