• 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 
16 #ifndef HISTREAMER_PIPELINE_DUMP_BUFFER_H
17 #define HISTREAMER_PIPELINE_DUMP_BUFFER_H
18 
19 #include <cstddef>
20 #include <cstdint>
21 #include <iosfwd>
22 #include <memory>
23 #include "plugin/common/plugin_buffer.h"
24 
25 namespace OHOS {
26 namespace Media {
27 namespace Pipeline {
28 // Modify DUMP_BUFFER2FILE_ENABLE to 1 to dump buffer to file.
29 #define DUMP_BUFFER2FILE_ENABLE 0
30 
31 // Modify DUMP_BUFFER2LOG_ENABLE to 1 to dump buffer first 10 bytes to log.
32 #define DUMP_BUFFER2LOG_ENABLE 0
33 
34 #if DUMP_BUFFER2FILE_ENABLE
35 #define DUMP_BUFFER2FILE(fileName, buffer) OHOS::Media::Pipeline::DumpBufferToFile(fileName, buffer)
36 #define DUMP_BUFFER2FILE_PREPARE() OHOS::Media::Pipeline::PrepareDumpDir()
37 #else
38 #define DUMP_BUFFER2FILE(fileName, buffer)
39 #define DUMP_BUFFER2FILE_PREPARE()
40 #endif
41 
42 #define DUMP_BUFFER2LOG_SIZE 10 // Dump first 10 bytes of buffer.
43 #if DUMP_BUFFER2LOG_ENABLE
44 #define DUMP_BUFFER2LOG(desc, buffer, offset) \
45     OHOS::Media::Pipeline::DumpBufferToLog(desc, buffer, offset, DUMP_BUFFER2LOG_SIZE)
46 #else
47 #define DUMP_BUFFER2LOG(desc, buffer, offset)
48 #endif
49 
50 void DumpBufferToFile(const std::string& fileName, const std::shared_ptr<Plugin::Buffer>& buffer);
51 void PrepareDumpDir();
52 void DumpBufferToLog(const char* desc, const std::shared_ptr<Plugin::Buffer>& buffer, uint64_t offset, size_t dumpSize);
53 } // Pipeline
54 } // Media
55 } // OHOS
56 #endif // HISTREAMER_PIPELINE_DUMP_BUFFER_H
57