2022-02-03 03:51:07 +08:00
|
|
|
#ifndef SC_DEMUXER_H
|
|
|
|
#define SC_DEMUXER_H
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
|
|
|
|
#include "trait/packet_sink.h"
|
|
|
|
#include "util/net.h"
|
|
|
|
#include "util/thread.h"
|
|
|
|
|
|
|
|
#define SC_DEMUXER_MAX_SINKS 2
|
|
|
|
|
|
|
|
struct sc_demuxer {
|
2023-02-19 07:13:54 +08:00
|
|
|
const char *name; // must be statically allocated (e.g. a string literal)
|
|
|
|
|
2022-02-03 03:51:07 +08:00
|
|
|
sc_socket socket;
|
|
|
|
sc_thread thread;
|
|
|
|
|
|
|
|
struct sc_packet_sink *sinks[SC_DEMUXER_MAX_SINKS];
|
|
|
|
unsigned sink_count;
|
|
|
|
|
|
|
|
const struct sc_demuxer_callbacks *cbs;
|
|
|
|
void *cbs_userdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sc_demuxer_callbacks {
|
2023-02-11 01:54:46 +08:00
|
|
|
void (*on_ended)(struct sc_demuxer *demuxer, bool eos, void *userdata);
|
2022-02-03 03:51:07 +08:00
|
|
|
};
|
|
|
|
|
2023-02-19 07:13:54 +08:00
|
|
|
// The name must be statically allocated (e.g. a string literal)
|
2022-02-03 03:51:07 +08:00
|
|
|
void
|
2023-02-19 07:13:54 +08:00
|
|
|
sc_demuxer_init(struct sc_demuxer *demuxer, const char *name, sc_socket socket,
|
2022-02-03 03:51:07 +08:00
|
|
|
const struct sc_demuxer_callbacks *cbs, void *cbs_userdata);
|
|
|
|
|
|
|
|
void
|
|
|
|
sc_demuxer_add_sink(struct sc_demuxer *demuxer, struct sc_packet_sink *sink);
|
|
|
|
|
|
|
|
bool
|
|
|
|
sc_demuxer_start(struct sc_demuxer *demuxer);
|
|
|
|
|
|
|
|
void
|
|
|
|
sc_demuxer_join(struct sc_demuxer *demuxer);
|
|
|
|
|
|
|
|
#endif
|