From: Agnieszka Janowicz Date: Mon, 21 Dec 2015 14:09:53 +0000 (+0100) Subject: [SAMPLE APP][Stream-player] File information X-Git-Tag: tizen_3.0/TD_SYNC/20161201~203^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89c97f6fad755d4ee19cbcbbdfa032b08d215712;p=sdk%2Fonline-doc.git [SAMPLE APP][Stream-player] File information Change-Id: I4356e69b89653f208f4e562b8f02c55ef5728007 Signed-off-by: Michal Skorupinski Signed-off-by: Agnieszka Janowicz --- diff --git a/org.tizen.sampledescriptions/html/mobile_n/stream-player-mn.html b/org.tizen.sampledescriptions/html/mobile_n/stream-player-mn.html index c7d6be6..d2b8953 100644 --- a/org.tizen.sampledescriptions/html/mobile_n/stream-player-mn.html +++ b/org.tizen.sampledescriptions/html/mobile_n/stream-player-mn.html @@ -393,6 +393,95 @@ static Eina_Bool __add_option_panel(void) +
Information popup
+

The information popup displays a text message with all information about a file gathered by the model. The function below generates the message.

+
+static char *__get_stream_info(void)
+{
+   // Variables declaration
+
+   dlog_print(DLOG_DEBUG, LOG_TAG, "===== Stream info =====");
+
+   __append_content_info(PLAYER_CONTENT_INFO_ALBUM,  msg, "Album: ");
+   __append_content_info(PLAYER_CONTENT_INFO_ARTIST, msg, "Artist: ");
+   __append_content_info(PLAYER_CONTENT_INFO_AUTHOR, msg, "Author: ");
+   __append_content_info(PLAYER_CONTENT_INFO_GENRE,  msg, "Genre: ");
+   __append_content_info(PLAYER_CONTENT_INFO_TITLE,  msg, "Title: ");
+   __append_content_info(PLAYER_CONTENT_INFO_YEAR,   msg, "Year: ");
+
+   player_model_get_codec(&audio_codec, &video_codec);
+   dlog_print(DLOG_DEBUG, LOG_TAG, "CODECS Audio: %s; Video: %s", audio_codec, video_codec);
+   __append_underlined_text(msg, "Codecs:");
+   __append_bolded_text(msg, "Audio: ", "%s%s", audio_codec, NEW_LINE);
+   __append_bolded_text(msg, "Video: ", "%s%s", video_codec, NEW_LINE);
+   free(audio_codec);
+   free(video_codec);
+
+   player_model_get_audio_stream_info(&sample_rate, &channel, &bit_rate);
+   dlog_print(DLOG_DEBUG, LOG_TAG, "AUDIO STREAM INFO: sample rate: %d; channel: %d; bit rate: %d", sample_rate, channel, bit_rate);
+   __append_underlined_text(msg, "Audio stream info:");
+   __append_bolded_text(msg, "Sample rate: ", "%d%s", sample_rate, NEW_LINE);
+   __append_bolded_text(msg, "Channel: ", "%d%s", channel, NEW_LINE);
+   __append_bolded_text(msg, "Bit rate: ", "%d%s", bit_rate, NEW_LINE);
+
+   player_model_get_video_stream_info(&fps, &bit_rate);
+   player_model_get_video_size(&width, &height);
+   dlog_print(DLOG_DEBUG, LOG_TAG, "VIDEO STREAM INFO: FPS: %d; bit_rate: %d; size=[%d, %d]", fps, bit_rate, width, height);
+   __append_underlined_text(msg, "Video stream info:");
+   __append_bolded_text(msg, "FPS: ", "%d%s", fps, NEW_LINE);
+   __append_bolded_text(msg, "Bit rate: ", "%d%s", bit_rate, NEW_LINE);
+   __append_bolded_text(msg, "Size: ", "%d x %d", width, height);
+
+   dlog_print(DLOG_DEBUG, LOG_TAG, "===== Stream info =====");
+
+   eina_strbuf_replace_all(msg, "&", "&"); //Every '&' character has to be replaced with '&'
+   ret = eina_strbuf_string_steal(msg);
+   eina_strbuf_free(msg);
+
+   return ret;
+}
+
+

The text part of the popup uses tags similar to the HTML's ones. This can used to bold or underline parts of the text.

+
+static inline Eina_Stringshare *__bold_text(char *txt)
+{
+   // Error handling
+   return eina_stringshare_printf("<font_weight=bold>%s</font_weight>", txt); //<font_weight=bold>%s</font_weight> %s will be bolded
+}
+
+static inline void __append_bolded_text(Eina_Strbuf *msg, char *key, char *format, ...)
+{
+   va_list args;
+   Eina_Stringshare *bolded = __bold_text(key);
+   va_start(args, format);
+   eina_strbuf_append(msg, bolded);
+   eina_strbuf_append_vprintf(msg, format, args);
+   eina_stringshare_del(bolded);
+   va_end(args);
+}
+
+static inline Eina_Stringshare *__underline_text(const char *txt, const char *color)
+{
+   // Error handling
+   return eina_stringshare_printf("<underline=on underline_color=%s>%s</underline>", color ? color : "#000000", txt);
+   //"<underline=on underline_color=%s>%s</underline> %s will be underlined. Note that the default color of the underline is white.
+}
+
+static inline void __append_underlined_text(Eina_Strbuf *msg, const char *txt)
+{
+   Eina_Stringshare *underlined = __underline_text(txt, "#000000");
+   eina_strbuf_append_printf(msg, "%s%s", underlined, NEW_LINE);
+   eina_stringshare_del(underlined);
+}
+
+

Refer to the links below for information about the tags:

+ + + +

Model

The image below describes the typical state changes of the player.

@@ -565,6 +654,62 @@ static void __insert_image_info_to_db(const char *path) +

Another feature of the sample application is file's information displaying. Multimedia files provide information about their content which can be accessed using the Player API. The data include:

+
    +
  • album name,
  • +
  • artist name,
  • +
  • author name,
  • +
  • genre,
  • +
  • title,
  • +
  • year,
  • +
  • audio codec name,
  • +
  • video codec name,
  • +
  • audio sample rate,
  • +
  • audio channel,
  • +
  • audio bit rate,
  • +
  • video frames per second,
  • +
  • video bit rate,
  • +
  • video size.
  • +
+

The functions below are used to get the file's information.

+
+char *player_model_get_content_info(player_content_info_e key)
+{
+   char *value = NULL;
+
+   // Error handling
+
+   player_get_content_info(s_info.player, key, &value);
+   dlog_print(DLOG_INFO, LOG_TAG, "player_model_content_info_get(%d) == %s", key, value);
+   return value;
+}
+
+void player_model_get_codec(char **audio_codec, char **video_codec)
+{
+   // Error handling
+   player_get_codec_info(s_info.player, audio_codec, video_codec);
+}
+
+void player_model_get_audio_stream_info(int *sample_rate, int *channel, int *bit_rate)
+{
+   // Error handling
+   player_get_audio_stream_info(s_info.player, sample_rate, channel, bit_rate);
+}
+
+void player_model_get_video_stream_info(int *fps, int *bit_rate)
+{
+   // Error handling
+   player_get_video_stream_info(s_info.player, fps, bit_rate);
+}
+
+void player_model_get_video_size(int *width, int *height)
+{
+   // Error handling
+   player_get_video_size(s_info.player, width, height);
+}
+
+

Note that not every file provides all the mentioned data.

+