2019-03-02 23:43:43 +08:00
|
|
|
#ifndef STREAM_H
|
|
|
|
#define STREAM_H
|
|
|
|
|
2021-01-09 02:24:51 +08:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-03-03 06:52:22 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2019-07-31 07:55:32 +08:00
|
|
|
#include <libavformat/avformat.h>
|
2019-03-02 23:43:43 +08:00
|
|
|
|
2021-04-11 21:01:05 +08:00
|
|
|
#include "trait/packet_sink.h"
|
2019-11-24 18:53:00 +08:00
|
|
|
#include "util/net.h"
|
2021-02-01 01:24:35 +08:00
|
|
|
#include "util/thread.h"
|
2019-03-02 23:43:43 +08:00
|
|
|
|
2021-04-11 21:01:05 +08:00
|
|
|
#define STREAM_MAX_SINKS 2
|
|
|
|
|
2019-03-02 23:43:43 +08:00
|
|
|
struct stream {
|
2021-10-27 04:49:45 +08:00
|
|
|
sc_socket socket;
|
2021-02-01 01:24:35 +08:00
|
|
|
sc_thread thread;
|
2021-04-11 21:01:05 +08:00
|
|
|
|
|
|
|
struct sc_packet_sink *sinks[STREAM_MAX_SINKS];
|
|
|
|
unsigned sink_count;
|
|
|
|
|
2019-07-31 07:55:32 +08:00
|
|
|
AVCodecContext *codec_ctx;
|
|
|
|
AVCodecParserContext *parser;
|
|
|
|
// successive packets may need to be concatenated, until a non-config
|
|
|
|
// packet is available
|
2021-06-14 15:07:49 +08:00
|
|
|
AVPacket *pending;
|
2021-05-16 21:32:31 +08:00
|
|
|
|
|
|
|
const struct stream_callbacks *cbs;
|
|
|
|
void *cbs_userdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stream_callbacks {
|
|
|
|
void (*on_eos)(struct stream *stream, void *userdata);
|
2019-03-02 23:43:43 +08:00
|
|
|
};
|
|
|
|
|
2019-03-03 03:09:56 +08:00
|
|
|
void
|
2021-10-27 04:49:45 +08:00
|
|
|
stream_init(struct stream *stream, sc_socket socket,
|
2021-05-16 21:32:31 +08:00
|
|
|
const struct stream_callbacks *cbs, void *cbs_userdata);
|
2021-04-11 21:01:05 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
stream_add_sink(struct stream *stream, struct sc_packet_sink *sink);
|
2019-03-03 03:09:56 +08:00
|
|
|
|
2019-03-03 06:52:22 +08:00
|
|
|
bool
|
2019-03-03 03:09:56 +08:00
|
|
|
stream_start(struct stream *stream);
|
|
|
|
|
|
|
|
void
|
|
|
|
stream_join(struct stream *stream);
|
2019-03-02 23:43:43 +08:00
|
|
|
|
|
|
|
#endif
|