• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2023 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 
16 #ifndef HISTREAMER_PIPELINE_DUMP_BUFFER_H
17 #define HISTREAMER_PIPELINE_DUMP_BUFFER_H
18 
19 #define DEMUXER_INPUT_PEEK "hst_dump_demuxer_input_peek.data"
20 #define DEMUXER_INPUT_GET "hst_dump_demuxer_input_get.data"
21 #define DEMUXER_OUTPUT "hst_dump_demuxer_output.data"
22 #define DECODER_OUTPUT "hst_dump_decoder_output.data"
23 
24 #include <cstddef>
25 #include <cstdint>
26 #include <iosfwd>
27 #include <memory>
28 #include "plugin/plugin_buffer.h"
29 
30 namespace OHOS {
31 namespace Media {
32 // Modify DUMP_BUFFER2FILE_ENABLE to 1 to dump buffer to file.
33 #ifndef DUMP_BUFFER2FILE_ENABLE
34 #define DUMP_BUFFER2FILE_ENABLE 0
35 #endif
36 
37 // Modify DUMP_BUFFER2LOG_ENABLE to 1 to dump buffer first 10 bytes to log.
38 #ifndef DUMP_BUFFER2LOG_ENABLE
39 #define DUMP_BUFFER2LOG_ENABLE 0
40 #endif
41 
42 #if DUMP_BUFFER2FILE_ENABLE
43 #define DUMP_BUFFER2FILE(fileName, buffer) OHOS::Media::Pipeline::DumpBufferToFile(fileName, buffer)
44 #define DUMP_BUFFER2FILE_PREPARE() OHOS::Media::Pipeline::PrepareDumpDir()
45 #define DUMP_BUFFER2FILE_END() OHOS::Media::Pipeline::EndDumpFile()
46 #else
47 #define DUMP_BUFFER2FILE(fileName, buffer)
48 #define DUMP_BUFFER2FILE_PREPARE()
49 #define DUMP_BUFFER2FILE_END()
50 #endif
51 
52 #define DUMP_BUFFER2LOG_SIZE 10 // Dump first 10 bytes of buffer.
53 #if DUMP_BUFFER2LOG_ENABLE
54 #define DUMP_BUFFER2LOG(desc, buffer, offset) \
55     OHOS::Media::Pipeline::DumpBufferToLog(desc, buffer, offset, DUMP_BUFFER2LOG_SIZE)
56 #else
57 #define DUMP_BUFFER2LOG(desc, buffer, offset)
58 #endif
59 
60 void DumpBufferToFile(const std::string& fileName, const std::shared_ptr<Plugins::Buffer>& buffer);
61 void PrepareDumpDir();
62 void EndDumpFile();
63 void DumpBufferToLog(const char* desc, const std::shared_ptr<Plugins::Buffer>& buffer, uint64_t offset,
64     size_t dumpSize);
65 } // Media
66 } // OHOS
67 #endif // HISTREAMER_PIPELINE_DUMP_BUFFER_H
68