[transcode] Implement new ffmpeg decoding methods: avcodec_send_packet/avcodec_receive_frame

This commit is contained in:
ejurgensen
2017-02-26 23:41:30 +01:00
parent 5afed60a42
commit e96b9500db
6 changed files with 249 additions and 258 deletions

View File

@@ -42,13 +42,13 @@ transcode_needed(const char *user_agent, const char *client_codecs, char *file_c
// Cleaning up
void
transcode_decode_cleanup(struct decode_ctx *ctx);
transcode_decode_cleanup(struct decode_ctx **ctx);
void
transcode_encode_cleanup(struct encode_ctx *ctx);
transcode_encode_cleanup(struct encode_ctx **ctx);
void
transcode_cleanup(struct transcode_ctx *ctx);
transcode_cleanup(struct transcode_ctx **ctx);
void
transcode_decoded_free(struct decoded_frame *decoded);
@@ -57,35 +57,36 @@ transcode_decoded_free(struct decoded_frame *decoded);
/* Demuxes and decodes the next packet from the input.
*
* @out decoded A newly allocated struct with a pointer to the frame and the
* stream. Must be freed with transcode_decoded_free().
* @in ctx Decode context
* @return Positive if OK, negative if error, 0 if EOF
* @out decoded A newly allocated struct with a pointer to the frame and the
* stream. Must be freed with transcode_decoded_free().
* @in ctx Decode context
* @return Positive if OK, negative if error, 0 if EOF
*/
int
transcode_decode(struct decoded_frame **decoded, struct decode_ctx *ctx);
/* Encodes and remuxes a frame. Also resamples if needed.
*
* @out evbuf An evbuffer filled with remuxed data
* @in frame The frame to encode, e.g. from transcode_decode
* @in wanted Bytes that the caller wants processed
* @in ctx Encode context
* @return Length of evbuf if OK, negative if error
* @out evbuf An evbuffer filled with remuxed data
* @in frame The frame to encode, e.g. from transcode_decode
* @in ctx Encode context
* @return Bytes added if OK, negative if error
*/
int
transcode_encode(struct evbuffer *evbuf, struct decoded_frame *decoded, struct encode_ctx *ctx);
/* Demuxes, decodes, encodes and remuxes the next packet from the input.
/* Demuxes, decodes, encodes and remuxes from the input.
*
* @out evbuf An evbuffer filled with remuxed data
* @in wanted Bytes that the caller wants processed
* @in ctx Transcode context
* @out icy_timer True if METADATA_ICY_INTERVAL has elapsed
* @return Bytes processed if OK, negative if error, 0 if EOF
* @out evbuf An evbuffer filled with remuxed data
* @in want_bytes Minimum number of bytes the caller wants added to the evbuffer
* - set want_bytes to 0 to transcode everything until EOF/error
* - set want_bytes to 1 to get one encoded packet
* @in ctx Transcode context
* @out icy_timer True if METADATA_ICY_INTERVAL has elapsed
* @return Bytes added if OK, negative if error, 0 if EOF
*/
int
transcode(struct evbuffer *evbuf, int wanted, struct transcode_ctx *ctx, int *icy_timer);
transcode(struct evbuffer *evbuf, int want_bytes, struct transcode_ctx *ctx, int *icy_timer);
struct decoded_frame *
transcode_raw2frame(uint8_t *data, size_t size);