[transcode] Update to new ffmpeg api - part 1

- no more use of AVStream.codec
- ditch some backwards compability
- move closer to being able do video, at least for artwork
This commit is contained in:
ejurgensen 2017-02-26 15:32:37 +01:00
parent b71b32438b
commit 25c1795af2
5 changed files with 531 additions and 711 deletions

View File

@ -552,7 +552,7 @@ httpd_stream_file(struct evhttp_request *req, int id)
stream_cb = stream_chunk_xcode_cb; stream_cb = stream_chunk_xcode_cb;
st->xcode = transcode_setup(mfi->data_kind, mfi->path, mfi->song_length, XCODE_PCM16_HEADER, &st->size); st->xcode = transcode_setup(XCODE_PCM16_HEADER, mfi->data_kind, mfi->path, mfi->song_length, &st->size);
if (!st->xcode) if (!st->xcode)
{ {
DPRINTF(E_WARN, L_HTTPD, "Transcoding setup failed, aborting streaming\n"); DPRINTF(E_WARN, L_HTTPD, "Transcoding setup failed, aborting streaming\n");

View File

@ -299,7 +299,7 @@ streaming_init(void)
return -1; return -1;
} }
streaming_encode_ctx = transcode_encode_setup(decode_ctx, XCODE_MP3, NULL); streaming_encode_ctx = transcode_encode_setup(XCODE_MP3, decode_ctx, NULL);
transcode_decode_cleanup(decode_ctx); transcode_decode_cleanup(decode_ctx);
if (!streaming_encode_ctx) if (!streaming_encode_ctx)
{ {

View File

@ -31,7 +31,7 @@
static int static int
setup(struct player_source *ps) setup(struct player_source *ps)
{ {
ps->input_ctx = transcode_setup(ps->data_kind, ps->path, ps->len_ms, XCODE_PCM16_NOHEADER, NULL); ps->input_ctx = transcode_setup(XCODE_PCM16_NOHEADER, ps->data_kind, ps->path, ps->len_ms, NULL);
if (!ps->input_ctx) if (!ps->input_ctx)
return -1; return -1;

File diff suppressed because it is too large Load Diff

View File

@ -6,19 +6,17 @@
#include "db.h" #include "db.h"
#include "http.h" #include "http.h"
#define XCODE_WAVHEADER (1 << 14)
#define XCODE_HAS_VIDEO (1 << 15)
enum transcode_profile enum transcode_profile
{ {
// Transcodes the best available audio stream into PCM16 (does not add wav header) // Transcodes the best audio stream into PCM16 (does not add wav header)
XCODE_PCM16_NOHEADER = 1, XCODE_PCM16_NOHEADER,
// Transcodes the best available audio stream into PCM16 (with wav header) // Transcodes the best audio stream into PCM16 (with wav header)
XCODE_PCM16_HEADER = XCODE_WAVHEADER | 2, XCODE_PCM16_HEADER,
// Transcodes the best available audio stream into MP3 // Transcodes the best audio stream into MP3
XCODE_MP3 = 3, XCODE_MP3,
// Transcodes video + audio + subtitle streams (not tested - for future use) // Transcodes the best video stream into JPEG/PNG
XCODE_H264_AAC = XCODE_HAS_VIDEO | 4, XCODE_JPEG,
XCODE_PNG,
}; };
struct decode_ctx; struct decode_ctx;
@ -28,13 +26,13 @@ struct decoded_frame;
// Setting up // Setting up
struct decode_ctx * struct decode_ctx *
transcode_decode_setup(enum data_kind data_kind, const char *path, uint32_t song_length, int decode_video); transcode_decode_setup(enum transcode_profile profile, enum data_kind data_kind, const char *path, uint32_t song_length);
struct encode_ctx * struct encode_ctx *
transcode_encode_setup(struct decode_ctx *src_ctx, enum transcode_profile profile, off_t *est_size); transcode_encode_setup(enum transcode_profile profile, struct decode_ctx *src_ctx, off_t *est_size);
struct transcode_ctx * struct transcode_ctx *
transcode_setup(enum data_kind data_kind, const char *path, uint32_t song_length, enum transcode_profile profile, off_t *est_size); transcode_setup(enum transcode_profile profile, enum data_kind data_kind, const char *path, uint32_t song_length, off_t *est_size);
struct decode_ctx * struct decode_ctx *
transcode_decode_setup_raw(void); transcode_decode_setup_raw(void);