Scanner C++ API
ffmpeg.h
1 /* Copyright 2016 Carnegie Mellon University, NVIDIA Corporation
2  *
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 #pragma once
17 
18 #ifdef HAVE_FFMPEG
19 
20 #include "scanner/util/common.h"
21 #include "storehouse/storage_backend.h"
22 
23 extern "C" {
24 #include "libavcodec/avcodec.h"
25 #include "libavfilter/avfilter.h"
26 #include "libavformat/avformat.h"
27 #include "libavformat/avio.h"
28 #include "libavutil/error.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/pixdesc.h"
31 #include "libswscale/swscale.h"
32 }
33 
34 using storehouse::RandomReadFile;
35 
36 namespace scanner {
37 
38 struct FFStorehouseState {
39  std::unique_ptr<RandomReadFile> file = nullptr;
40  u64 size = 0; // total file size
41  u64 pos = 0;
42 
43  u64 buffer_start = 0;
44  u64 buffer_end = 0;
45  std::vector<u8> buffer;
46 };
47 
48 bool ffmpeg_storehouse_state_init(FFStorehouseState* file_state,
49  storehouse::StorageBackend* storage,
50  const std::string& path,
51  std::string& error_message);
52 
53 // For custom AVIOContext that loads from memory
54 i32 ffmpeg_storehouse_read_packet(void* opaque, u8* buf, i32 buf_size);
55 
56 i64 ffmpeg_storehouse_seek(void* opaque, i64 offset, i32 whence);
57 
58 } // namespace scanner
59 
60 #endif
Definition: database.cpp:36