e8b053ad2f
From FFmpeg/doc/APIchanges: 2021-03-17 - f7db77bd87 - lavc 58.133.100 - codec.h Deprecated av_init_packet(). Once removed, sizeof(AVPacket) will no longer be a part of the public ABI. Remove the has_pending boolean, which can be replaced by: stream->pending != NULL Refs #2302 <https://github.com/Genymobile/scrcpy/issues/2302>
50 lines
1,018 B
C
50 lines
1,018 B
C
#ifndef STREAM_H
|
|
#define STREAM_H
|
|
|
|
#include "common.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include "trait/packet_sink.h"
|
|
#include "util/net.h"
|
|
#include "util/thread.h"
|
|
|
|
#define STREAM_MAX_SINKS 2
|
|
|
|
struct stream {
|
|
socket_t socket;
|
|
sc_thread thread;
|
|
|
|
struct sc_packet_sink *sinks[STREAM_MAX_SINKS];
|
|
unsigned sink_count;
|
|
|
|
AVCodecContext *codec_ctx;
|
|
AVCodecParserContext *parser;
|
|
// successive packets may need to be concatenated, until a non-config
|
|
// packet is available
|
|
AVPacket *pending;
|
|
|
|
const struct stream_callbacks *cbs;
|
|
void *cbs_userdata;
|
|
};
|
|
|
|
struct stream_callbacks {
|
|
void (*on_eos)(struct stream *stream, void *userdata);
|
|
};
|
|
|
|
void
|
|
stream_init(struct stream *stream, socket_t socket,
|
|
const struct stream_callbacks *cbs, void *cbs_userdata);
|
|
|
|
void
|
|
stream_add_sink(struct stream *stream, struct sc_packet_sink *sink);
|
|
|
|
bool
|
|
stream_start(struct stream *stream);
|
|
|
|
void
|
|
stream_join(struct stream *stream);
|
|
|
|
#endif
|