Line data Source code
1 : /*
2 : * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 : *
4 : * This program is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 3 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * This program is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 : */
17 :
18 : #ifndef __MEDIA_IO_HANDLE_H__
19 : #define __MEDIA_IO_HANDLE_H__
20 :
21 : #include "noncopyable.h"
22 :
23 : #include <cstdlib>
24 : #include <cstdint>
25 : #include <libavformat/version_major.h>
26 :
27 : #ifndef AVFORMAT_AVIO_H
28 : struct AVIOContext;
29 : #endif
30 :
31 : typedef int (*io_readcallback)(void* opaque, uint8_t* buf, int buf_size);
32 : #if LIBAVFORMAT_VERSION_MAJOR >= 61
33 : using io_writebuffer = const uint8_t;
34 : #else
35 : using io_writebuffer = uint8_t;
36 : #endif
37 : typedef int (*io_writecallback)(void* opaque, io_writebuffer* buf, int buf_size);
38 : typedef int64_t (*io_seekcallback)(void* opaque, int64_t offset, int whence);
39 :
40 : namespace jami {
41 :
42 : class MediaIOHandle
43 : {
44 : public:
45 : MediaIOHandle(std::size_t buffer_size,
46 : bool writeable,
47 : io_readcallback read_cb,
48 : io_writecallback write_cb,
49 : io_seekcallback seek_cb,
50 : void* opaque);
51 : ~MediaIOHandle();
52 :
53 1179 : AVIOContext* getContext() { return ctx_; }
54 :
55 : private:
56 : NON_COPYABLE(MediaIOHandle);
57 : AVIOContext* ctx_;
58 : };
59 :
60 : } // namespace jami
61 :
62 : #endif // __MEDIA_DECODER_H__
|