Merge lp:~d.filoni/media-hub/improve_content_type_recognition into lp:media-hub

Proposed by Devid Antonio Filoni
Status: Needs review
Proposed branch: lp:~d.filoni/media-hub/improve_content_type_recognition
Merge into: lp:media-hub
Diff against target: 29 lines (+19/-1)
1 file modified
src/core/media/gstreamer/playbin.cpp (+19/-1)
To merge this branch: bzr merge lp:~d.filoni/media-hub/improve_content_type_recognition
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+310339@code.launchpad.net

Description of the change

file_info_from_uri (gstreamer/playbin.cpp) cannot recognize content type of remote files. When the content type is not recognized "audio/video/" is returned as content type, however, as is_video_file function searches for a content type starting with "video/", a video is never recognized and only the audio is played as described in bug #1446260 (is_video_file always returns false and is_audio_file returns true so MEDIA_FILE_TYPE_AUDIO is set as file_type)
Proposed branch calls g_content_type_guess on filename in order to try to find content type parsing file extension only when a content type was not found by file_info_from_uri. This branch is not a real fix for bug #1446260, the real solution would be to parse content type from remote files, however it helps to recognize many video files (like the one in bug description).
In order to avoid regressions, g_content_type_guess output is considered valid only if a "video/" content type is recognized, otherwise it will fails to "audio/video/".

What I tested on mako:
- local files (video)
- bug #1446260 : mediaplayer-app http://wbads.vo.llnwd.net/o25/u/telepixtv/videos/ellen/20150320/594/0_fu4qgsy7_0_obx408yq_2.mp4 --desktop_file_hint=/usr/share/applications/mediaplayer-app.desktop
- uradio
Everything works fine.

To post a comment you must log in.

Unmerged revisions

212. By Devid Antonio Filoni

Improve gstreamer playbin get_file_content_type using g_content_type_guess as fallback when no content type is found by file_info_from_uri

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/media/gstreamer/playbin.cpp'
2--- src/core/media/gstreamer/playbin.cpp 2016-07-11 01:21:38 +0000
3+++ src/core/media/gstreamer/playbin.cpp 2016-11-08 17:07:28 +0000
4@@ -786,7 +786,25 @@
5 const std::string content_type {file_info_from_uri(encoded_uri)};
6 if (content_type.empty())
7 {
8- MH_WARNING("Failed to get actual track content type");
9+ gboolean is_certain = FALSE;
10+ std::string guessed_content_type(g_content_type_guess(uri.c_str(), NULL, 0, &is_certain));
11+ if (guessed_content_type.find("video/") != 0)
12+ {
13+ std::string::size_type question_mark_pos = uri.find('?');
14+ if (question_mark_pos != std::string::npos)
15+ {
16+ is_certain = FALSE;
17+ guessed_content_type = g_content_type_guess(uri.substr(0, question_mark_pos).c_str(), NULL, 0, &is_certain);
18+ }
19+ }
20+
21+ if (guessed_content_type.find("video/") == 0)
22+ {
23+ MH_INFO("Guessed content type: %s", guessed_content_type);
24+ return guessed_content_type;
25+ }
26+
27+ MH_WARNING("Failed to get actual track content type, falling back to audio");
28 return std::string("audio/video/");
29 }
30

Subscribers

People subscribed via source and target branches