Porting to libav v11
[platform/upstream/lightmediascanner.git] / src / plugins / generic / generic.c
index 2e54ded..74c2240 100644 (file)
@@ -24,6 +24,7 @@
 #include "libavutil/opt.h"
 
 #include <lightmediascanner_db.h>
+#include <lightmediascanner_dlna.h>
 #include <lightmediascanner_plugin.h>
 
 #include <sys/types.h>
@@ -49,16 +50,20 @@ static const struct lms_string_size _exts[] = {
     LMS_STATIC_STRING_SIZE(".m3u"),
     LMS_STATIC_STRING_SIZE(".mp4"),
     LMS_STATIC_STRING_SIZE(".wma"),
+    LMS_STATIC_STRING_SIZE(".ogg"),
 };
 
 DECL_STR(_codec_mpeg1layer3, "mpeg1layer3");
 DECL_STR(_container_3gp, "3gp");
 DECL_STR(_container_mp4, "mp4");
+DECL_STR(_container_ogg, "ogg");
 
 DECL_STR(_container_audio_wmav1, "wmav1");
 DECL_STR(_container_audio_wmav2, "wmav2");
 DECL_STR(_container_audio_wmavpro, "wmavpro");
 
+DECL_STR(_codec_video_theora, "theora");
+DECL_STR(_codec_audio_vorbis, "vorbis");
 DECL_STR(_codec_audio_asf, "asf");
 DECL_STR(_codec_audio_mpeg4aac_main, "mpeg4aac-main");
 DECL_STR(_codec_audio_mpeg4aac_lc, "mpeg4aac-lc");
@@ -81,10 +86,12 @@ struct codec_container_descriptor {
 };
 
 static const struct codec_container_descriptor _codec_list[] = {
-    {CODEC_ID_MP3, &_codec_mpeg1layer3},
+    {AV_CODEC_ID_MP3, &_codec_mpeg1layer3},
     {AV_CODEC_ID_WMAV1, &_codec_audio_asf},
     {AV_CODEC_ID_WMAV2, &_codec_audio_asf},
     {AV_CODEC_ID_WMAPRO, &_codec_audio_asf},
+    {AV_CODEC_ID_VORBIS, &_codec_audio_vorbis},
+    {AV_CODEC_ID_THEORA, &_codec_video_theora},
 };
 
 static const struct codec_container_descriptor _container_list[] = {
@@ -94,6 +101,8 @@ static const struct codec_container_descriptor _container_list[] = {
     {AV_CODEC_ID_WMAV2, &_container_audio_wmav2},
     {AV_CODEC_ID_WMAPRO, &_container_audio_wmavpro},
     {AV_CODEC_ID_H264, &_container_mp4},
+    {AV_CODEC_ID_VORBIS, &_container_ogg},
+    {AV_CODEC_ID_THEORA, &_container_ogg},
 };
 
 static void
@@ -242,11 +251,21 @@ _get_common_container(AVStream *stream, struct lms_string_size *value)
 
 static const struct codec_container _codecs[] = {
     {
-        .id = CODEC_ID_MP3,
+        .id = AV_CODEC_ID_MP3,
         .get_codec = _get_common_codec,
         .get_container = NULL,
     },
     {
+        .id = AV_CODEC_ID_VORBIS,
+        .get_codec = _get_common_codec,
+        .get_container = _get_common_container,
+    },
+    {
+        .id = AV_CODEC_ID_THEORA,
+        .get_codec = _get_common_codec,
+        .get_container = _get_common_container,
+    },
+    {
         .id = AV_CODEC_ID_AAC,
         .get_codec = _mp4_get_audio_codec,
         .get_container = _get_common_container,
@@ -416,8 +435,8 @@ _parse_video_stream(AVFormatContext *fmt_ctx, struct lms_video_info *info, AVStr
     s->video.width = ctx->width;
     s->video.height = ctx->height;
 
-    if (stream->r_frame_rate.den)
-        s->video.framerate = stream->r_frame_rate.num / stream->r_frame_rate.den;
+    if (stream->avg_frame_rate.den)
+        s->video.framerate = stream->avg_frame_rate.num / stream->avg_frame_rate.den;
 
     snprintf(aspect_ratio, sizeof(aspect_ratio), "%d:%d",
              ctx->sample_aspect_ratio.num, ctx->sample_aspect_ratio.den);
@@ -442,6 +461,8 @@ _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_in
     struct lms_video_info video_info = { };
     struct lms_string_size container = { };
     bool video = false;
+    const struct lms_dlna_video_profile *video_dlna;
+    const struct lms_dlna_audio_profile *audio_dlna;
 
     if (finfo->parsed)
         return 0;
@@ -529,6 +550,8 @@ _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_in
         video_info.container = container;
         video_info.packet_size = packet_size;
 
+        LMS_DLNA_GET_VIDEO_PROFILE_PATH_FB(&video_info, video_dlna,
+                                           finfo->path);
         ret = lms_db_video_add(plugin->video_db, &video_info);
     } else {
         audio_info.id = finfo->id;
@@ -538,7 +561,10 @@ _parse(struct plugin *plugin, struct lms_context *ctxt, const struct lms_file_in
         audio_info.genre = info.genre;
         audio_info.container = container;
 
+        LMS_DLNA_GET_AUDIO_PROFILE_PATH_FB(&audio_info, audio_dlna,
+                                           finfo->path);
         ret = lms_db_audio_add(plugin->audio_db, &audio_info);
+
         lms_string_size_strip_and_free(&audio_info.codec);
     }