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>
|
|
|
|
|
2023-03-02 16:20:37 +08:00
|
|
|
#include "trait/packet_source.h"
|
2022-02-03 03:51:07 +08:00
|
|
|
#include "trait/packet_sink.h"
|
|
|
|
#include "util/net.h"
|
|
|
|
#include "util/thread.h"
|
|
|
|
|
|
|
|
struct sc_demuxer {
|
2023-03-02 16:20:37 +08:00
|
|
|
struct sc_packet_source packet_source; // packet source trait
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
const struct sc_demuxer_callbacks *cbs;
|
|
|
|
void *cbs_userdata;
|
|
|
|
};
|
|
|
|
|
2023-03-01 04:19:43 +08:00
|
|
|
enum sc_demuxer_status {
|
|
|
|
SC_DEMUXER_STATUS_EOS,
|
|
|
|
SC_DEMUXER_STATUS_DISABLED,
|
|
|
|
SC_DEMUXER_STATUS_ERROR,
|
|
|
|
};
|
|
|
|
|
2022-02-03 03:51:07 +08:00
|
|
|
struct sc_demuxer_callbacks {
|
2023-03-01 04:19:43 +08:00
|
|
|
void (*on_ended)(struct sc_demuxer *demuxer, enum sc_demuxer_status,
|
|
|
|
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);
|
|
|
|
|
|
|
|
bool
|
|
|
|
sc_demuxer_start(struct sc_demuxer *demuxer);
|
|
|
|
|
|
|
|
void
|
|
|
|
sc_demuxer_join(struct sc_demuxer *demuxer);
|
|
|
|
|
|
|
|
#endif
|