sbGStreamerMediacoreUtils.cpp File Reference
#include "sbGStreamerMediacoreUtils.h"
#include <nsIRunnable.h>
#include <nsINetUtil.h>
#include <nsIWritablePropertyBag.h>
#include <nsAutoPtr.h>
#include <nsThreadUtils.h>
#include <nsTArray.h>
#include <nsMemory.h>
#include <sbStandardProperties.h>
#include <sbStringBundle.h>
#include <prlog.h>
#include <gst/gst.h>
Include dependency graph for sbGStreamerMediacoreUtils.cpp:

Go to the source code of this file.

Classes

class  sbGstMessageEvent
 
struct  errMap
 
struct  TypeMatchingInfo
 
struct  sb_gst_caps_map_entry
 

Macros

#define LOG(args)   /* nothing */
 
#define TRACE(args)   /* nothing */
 
#define SB_GN_PROP_EXTENDEDDATA   "http://gracenote.com/pos/1.0#extendedData"
 
#define SB_GN_PROP_TAGID   "http://gracenote.com/pos/1.0#tagId"
 
#define TAG_CONVERT_STRING(sbname, gstname)
 
#define TAG_CONVERT_UINT(sbname, gstname)
 
#define PROPERTY_CONVERT_STRING(propname, tagname)
 
#define PROPERTY_CONVERT_UINT(propname, tagname, scale)
 

Functions

PRBool ConvertSinglePropertyToTag (sbIProperty *property, GstTagList *taglist)
 
GstTagList * ConvertPropertyArrayToTagList (sbIPropertyArray *properties)
 
static void ConvertSingleTag (const GstTagList *taglist, const gchar *tag, gpointer user_data)
 
nsresult ConvertTagListToPropertyArray (GstTagList *taglist, sbIPropertyArray **aPropertyArray)
 
 NS_IMPL_THREADSAFE_ISUPPORTS1 (sbGstMessageEvent, nsIRunnable) GstBusSyncReply SyncToAsyncDispatcher(GstBus *bus
 
 if (!handled)
 
 gst_message_unref (message)
 
nsresult GetMediacoreErrorFromGstError (GError *gerror, nsString aResource, GStreamer::pipelineOp_t aPipelineOp, sbIMediacoreError **_retval)
 
static gboolean match_element_filter (GstPluginFeature *feature, TypeMatchingInfo *data)
 
const char * FindMatchingElementName (const char *srcCapsString, const char *typeName)
 
const char * FindMatchingElementName (GstCaps *srcCaps, const char *typeName)
 
void RegisterCustomTags ()
 
nsresult ApplyPropertyBagToElement (GstElement *element, nsIPropertyBag *props)
 
static nsCString GetGstCapsName (const nsACString &aMimeType, enum sbGstCapsMapType aType)
 
GstCaps * GetCapsForMimeType (const nsACString &aMimeType, enum sbGstCapsMapType aType)
 
nsresult GetMimeTypeForCaps (GstCaps *aCaps, nsACString &aMimeType)
 
static gboolean _OnEachGValue (GQuark aFieldId, const GValue *aValue, gpointer aUserData)
 
nsresult SetPropertiesFromGstStructure (nsIWritablePropertyBag2 *aPropertyBag, const GstStructure *aStructure, const gchar *const aDesiredFieldList[], PRUint32 aFieldCount)
 
nsresult SetPropertyFromGValue (nsIWritablePropertyBag2 *aPropertyBag, const nsAString &aProperty, const GValue *aValue)
 
GstPad * GetRealPad (GstPad *pad)
 

Variables

GstMessage * message
 
GstMessage gpointer data
sbGStreamerMessageHandler
handler
 
PRBool handled = handler->HandleSynchronousMessage(message)
 
return GST_BUS_DROP
 
static const struct errMap ResourceErrorMap []
 
static const struct errMap StreamErrorMap []
 
static const struct
sb_gst_caps_map_entry 
sb_gst_caps_map []
 

Macro Definition Documentation

#define LOG (   args)    /* nothing */

To log this class, set the following environment variable in a debug build:

NSPR_LOG_MODULES=sbGStreamerMediacoreUtils:5 (or :3 for LOG messages only)

Definition at line 65 of file sbGStreamerMediacoreUtils.cpp.

#define PROPERTY_CONVERT_STRING (   propname,
  tagname 
)
Value:
if (!strcmp(tag, tagname)) { \
gchar *tagvalue; \
if (gst_tag_list_get_string (taglist, tag, &tagvalue)) { \
propArray->AppendProperty(NS_LITERAL_STRING (propname), \
NS_ConvertUTF8toUTF16(tagvalue)); \
g_free (tagvalue); \
} \
}
if(!handled)
return
Definition: FeedWriter.js:850
dataSBGenres SBProperties tag
Definition: tuner2.js:871
#define PROPERTY_CONVERT_UINT (   propname,
  tagname,
  scale 
)
Value:
if (!strcmp(tag, tagname)) { \
guint tagvalue; \
if (gst_tag_list_get_uint (taglist, tag, &tagvalue)) { \
nsString stringVal; \
stringVal.AppendInt(tagvalue / scale); \
propArray->AppendProperty(NS_LITERAL_STRING (propname), \
stringVal); \
} \
}
if(!handled)
return
Definition: FeedWriter.js:850
dataSBGenres SBProperties tag
Definition: tuner2.js:871
#define SB_GN_PROP_EXTENDEDDATA   "http://gracenote.com/pos/1.0#extendedData"

Definition at line 107 of file sbGStreamerMediacoreUtils.cpp.

#define SB_GN_PROP_TAGID   "http://gracenote.com/pos/1.0#tagId"

Definition at line 108 of file sbGStreamerMediacoreUtils.cpp.

#define TAG_CONVERT_STRING (   sbname,
  gstname 
)
Value:
if (id == NS_LITERAL_STRING (sbname)) { \
NS_ConvertUTF16toUTF8 utf8value(value); \
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, (gchar *)gstname, \
utf8value.BeginReading(), NULL); \
return PR_TRUE; \
}
return
Definition: FeedWriter.js:850
countRef value
Definition: FeedWriter.js:1423
#define TAG_CONVERT_UINT (   sbname,
  gstname 
)
Value:
if (id == NS_LITERAL_STRING (sbname)) { \
unsigned int gstvalue = value.ToInteger(&rv); \
NS_ENSURE_SUCCESS (rv, PR_FALSE); \
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, (gchar *)gstname, \
gstvalue, NULL); \
return PR_TRUE; \
}
return
Definition: FeedWriter.js:850
countRef value
Definition: FeedWriter.js:1423
#define TRACE (   args)    /* nothing */

Definition at line 66 of file sbGStreamerMediacoreUtils.cpp.

Function Documentation

static gboolean _OnEachGValue ( GQuark  aFieldId,
const GValue *  aValue,
gpointer  aUserData 
)
static

Definition at line 881 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult ApplyPropertyBagToElement ( GstElement *  element,
nsIPropertyBag *  props 
)

Definition at line 629 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

GstTagList* ConvertPropertyArrayToTagList ( sbIPropertyArray properties)

Definition at line 192 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool ConvertSinglePropertyToTag ( sbIProperty property,
GstTagList *  taglist 
)

Definition at line 111 of file sbGStreamerMediacoreUtils.cpp.

Here is the caller graph for this function:

static void ConvertSingleTag ( const GstTagList *  taglist,
const gchar *  tag,
gpointer  user_data 
)
static

Definition at line 223 of file sbGStreamerMediacoreUtils.cpp.

Here is the caller graph for this function:

nsresult ConvertTagListToPropertyArray ( GstTagList *  taglist,
sbIPropertyArray **  aPropertyArray 
)

Definition at line 266 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const char* FindMatchingElementName ( const char *  srcCapsString,
const char *  typeName 
)

Find an element name for an element that can produce caps compatible with 'srcCapsString' on its source pad, and has a klass name include 'typeName'. Returns NULL if none is found.

e.g. Call FindMatchingElementName("application/ogg", "Muxer") to get an ogg muxer element name ("oggmux" will be returned).

Definition at line 572 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const char* FindMatchingElementName ( GstCaps *  srcCaps,
const char *  typeName 
)

Overload of the above, but accepting a GstCaps instead of a string

Definition at line 586 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

GstCaps* GetCapsForMimeType ( const nsACString &  aMimeType,
enum sbGstCapsMapType  aType 
)

Definition at line 813 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static nsCString GetGstCapsName ( const nsACString &  aMimeType,
enum sbGstCapsMapType  aType 
)
static

Definition at line 796 of file sbGStreamerMediacoreUtils.cpp.

Here is the caller graph for this function:

nsresult GetMediacoreErrorFromGstError ( GError *  gerror,
nsString  aResource,
GStreamer::pipelineOp_t  aPipelineOp,
sbIMediacoreError **  _retval 
)

Definition at line 410 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult GetMimeTypeForCaps ( GstCaps *  aCaps,
nsACString &  aMimeType 
)

Definition at line 824 of file sbGStreamerMediacoreUtils.cpp.

GstPad* GetRealPad ( GstPad *  pad)

Definition at line 1016 of file sbGStreamerMediacoreUtils.cpp.

gst_message_unref ( message  )

Here is the caller graph for this function:

if ( handled)

Definition at line 323 of file sbGStreamerMediacoreUtils.cpp.

static gboolean match_element_filter ( GstPluginFeature *  feature,
TypeMatchingInfo data 
)
static

Definition at line 518 of file sbGStreamerMediacoreUtils.cpp.

Here is the caller graph for this function:

NS_IMPL_THREADSAFE_ISUPPORTS1 ( sbGstMessageEvent  ,
nsIRunnable   
)
void RegisterCustomTags ( )

Definition at line 620 of file sbGStreamerMediacoreUtils.cpp.

Here is the caller graph for this function:

nsresult SetPropertiesFromGstStructure ( nsIWritablePropertyBag2 *  aPropertyBag,
const GstStructure *  aStructure,
const gchar *const  aDesiredFieldList[],
PRUint32  aFieldCount 
)

Definition at line 897 of file sbGStreamerMediacoreUtils.cpp.

Here is the call graph for this function:

nsresult SetPropertyFromGValue ( nsIWritablePropertyBag2 *  aPropertyBag,
const nsAString &  aProperty,
const GValue *  aValue 
)

Definition at line 933 of file sbGStreamerMediacoreUtils.cpp.

Here is the caller graph for this function:

Variable Documentation

return GST_BUS_DROP

Definition at line 330 of file sbGStreamerMediacoreUtils.cpp.

else handled = handler->HandleSynchronousMessage(message)

Definition at line 321 of file sbGStreamerMediacoreUtils.cpp.

GstMessage gpointer data sbGStreamerMessageHandler* handler
Initial value:

Definition at line 316 of file sbGStreamerMediacoreUtils.cpp.

GstMessage* message

Definition at line 314 of file sbGStreamerMediacoreUtils.cpp.

const struct errMap ResourceErrorMap[]
static
Initial value:
= {
{ GST_RESOURCE_ERROR_NOT_FOUND, GStreamer::OP_UNKNOWN,
"mediacore.error.resource_not_found"},
{ GST_RESOURCE_ERROR_READ, GStreamer::OP_UNKNOWN,
"mediacore.error.read_failed"},
{ GST_RESOURCE_ERROR_WRITE, GStreamer::OP_UNKNOWN,
"mediacore.error.write_failed"},
{ GST_RESOURCE_ERROR_OPEN_READ, GStreamer::OP_UNKNOWN,
"mediacore.error.read_open_failed"},
{ GST_RESOURCE_ERROR_OPEN_WRITE, GStreamer::OP_UNKNOWN,
"mediacore.error.write_open_failed"},
{ GST_RESOURCE_ERROR_OPEN_READ_WRITE, GStreamer::OP_UNKNOWN,
"mediacore.error.rw_open_failed"},
{ GST_RESOURCE_ERROR_CLOSE, GStreamer::OP_UNKNOWN,
"mediacore.error.close_failed"},
{ GST_RESOURCE_ERROR_SEEK, GStreamer::OP_UNKNOWN,
"mediacore.error.seek_failed"},
{ GST_RESOURCE_ERROR_NO_SPACE_LEFT, GStreamer::OP_UNKNOWN,
"mediacore.error.out_of_space"},
}
const unsigned long SB_RESOURCE_OPEN_READ
const unsigned long SB_RESOURCE_OPEN_WRITE
const unsigned long SB_RESOURCE_NO_SPACE_LEFT
const unsigned long SB_RESOURCE_CLOSE
const unsigned long SB_RESOURCE_OPEN_READ_WRITE
const unsigned long SB_RESOURCE_SEEK
const unsigned long SB_RESOURCE_READ
const unsigned long SB_RESOURCE_NOT_FOUND
const unsigned long SB_RESOURCE_WRITE

Definition at line 340 of file sbGStreamerMediacoreUtils.cpp.

const struct sb_gst_caps_map_entry sb_gst_caps_map[]
static
Initial value:
=
{
{ "audio/mpeg", "application/x-id3", SB_GST_CAPS_MAP_CONTAINER },
{ "video/3gpp", "video/quicktime", SB_GST_CAPS_MAP_CONTAINER },
{ "video/mp4", "video/quicktime", SB_GST_CAPS_MAP_CONTAINER },
{ "audio/x-pcm-int", "audio/x-raw-int", SB_GST_CAPS_MAP_AUDIO },
{ "audio/x-pcm-float", "audio/x-raw-float", SB_GST_CAPS_MAP_AUDIO },
{ "audio/x-ms-wma", "audio/x-wma", SB_GST_CAPS_MAP_AUDIO },
{ "audio/mpeg", "audio/mpeg", SB_GST_CAPS_MAP_AUDIO },
{ "audio/aac", "audio/mpeg", SB_GST_CAPS_MAP_AUDIO },
{ "video/x-ms-wmv", "video/x-wmv", SB_GST_CAPS_MAP_VIDEO },
{ "video/h264", "video/x-h264", SB_GST_CAPS_MAP_VIDEO },
{ "video/mpeg", "video/x-divx", SB_GST_CAPS_MAP_NONE },
{ "video/mpeg", "video/x-xvid", SB_GST_CAPS_MAP_NONE },
{ "video/mp4", "audio/x-m4a", SB_GST_CAPS_MAP_NONE },
{ "video/3gpp", "application/x-3gp", SB_GST_CAPS_MAP_NONE },
}

Definition at line 760 of file sbGStreamerMediacoreUtils.cpp.

const struct errMap StreamErrorMap[]
static
Initial value:
= {
{ GST_STREAM_ERROR_TYPE_NOT_FOUND, GStreamer::OP_UNKNOWN,
"mediacore.error.type_not_found"},
{ GST_STREAM_ERROR_WRONG_TYPE, GStreamer::OP_UNKNOWN,
"mediacore.error.wrong_type"},
{ GST_STREAM_ERROR_CODEC_NOT_FOUND, GStreamer::OP_UNKNOWN,
"mediacore.error.codec_not_found"},
{ GST_STREAM_ERROR_DECODE, GStreamer::OP_TRANSCODING,
"mediacore.error.decode_for_transcode_failed" },
{ GST_STREAM_ERROR_DECODE, GStreamer::OP_UNKNOWN,
"mediacore.error.decode_failed"},
{ GST_STREAM_ERROR_ENCODE, GStreamer::OP_UNKNOWN,
"mediacore.error.encode_failed"},
{ GST_STREAM_ERROR_FAILED, GStreamer::OP_TRANSCODING,
"mediacore.error.failure_during_transcode"},
{ GST_STREAM_ERROR_FAILED, GStreamer::OP_UNKNOWN,
"mediacore.error.failure"},
{ GST_STREAM_ERROR_DECRYPT, GStreamer::OP_UNKNOWN,
"mediacore.error.decrypt"},
}
const unsigned long SB_STREAM_DECODE
const unsigned long SB_STREAM_FAILURE
const unsigned long SB_STREAM_CODEC_NOT_FOUND
const unsigned long SB_STREAM_WRONG_TYPE
const unsigned long SB_STREAM_ENCODE
const unsigned long SB_STREAM_TYPE_NOT_FOUND

Definition at line 379 of file sbGStreamerMediacoreUtils.cpp.