media_io_handle.h 1.76 KB
Newer Older
1
/*
2
 *  Copyright (C) 2013-2017 Savoir-faire Linux Inc.
Guillaume Roguez's avatar
Guillaume Roguez committed
3
 *
4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *  Author: Guillaume Roguez <Guillaume.Roguez@savoirfairelinux.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
Guillaume Roguez's avatar
Guillaume Roguez committed
18
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
19 20 21 22 23 24 25
 */

#ifndef __MEDIA_IO_HANDLE_H__
#define __MEDIA_IO_HANDLE_H__

#include "noncopyable.h"

Guillaume Roguez's avatar
Guillaume Roguez committed
26 27
#include <cstdlib>
#include <cstdint>
Guillaume Roguez's avatar
Guillaume Roguez committed
28
#include <vector>
Guillaume Roguez's avatar
Guillaume Roguez committed
29

30 31 32 33 34 35 36 37 38 39 40 41
#ifndef AVFORMAT_AVIO_H
class AVIOContext;
#endif

typedef int(*io_readcallback)(void *opaque, uint8_t *buf, int buf_size);
typedef int(*io_writecallback)(void *opaque, uint8_t *buf, int buf_size);
typedef int64_t(*io_seekcallback)(void *opaque, int64_t offset, int whence);

namespace ring {

class MediaIOHandle {
public:
Guillaume Roguez's avatar
Guillaume Roguez committed
42
    MediaIOHandle(std::size_t buffer_size,
43 44 45 46 47 48 49 50 51 52 53 54
                  bool writeable,
                  io_readcallback read_cb,
                  io_writecallback write_cb,
                  io_seekcallback seek_cb,
                  void *opaque);
    ~MediaIOHandle();

    AVIOContext* getContext() { return ctx_; }

private:
    NON_COPYABLE(MediaIOHandle);
    AVIOContext *ctx_;
Guillaume Roguez's avatar
Guillaume Roguez committed
55
    std::vector<uint8_t> buf_ {};
56 57
};

Guillaume Roguez's avatar
Guillaume Roguez committed
58
} // namespace ring
59 60

#endif // __MEDIA_DECODER_H__