@@ -239,7 +239,14 @@ const char *gstGetMediaTypeName(GstMediaType mediaType)
239239
240240
241241static GstStateChangeReturn SetStateWithWarnings (GstElement *element, GstState targetState);
242+
243+ /* *
244+ * @brief Decorate a GstBuffer with DRM metadata
245+ * @param[in] buffer The GstBuffer to decorate
246+ * @param[in] drmMetadata The DRM metadata
247+ */
242248static void DecorateGstBufferWithDrmMetadata (GstBuffer *buffer, const MediaDrmMetadata &drmMetadata);
249+
243250/* *
244251 * @brief Configures the GStreamer pipeline.
245252 * @param format Video format.
@@ -2995,6 +3002,22 @@ void InterfacePlayerRDK::SetPlayerName(std::string name)
29953002 interfacePlayerPriv->mPlayerName = name;
29963003}
29973004
3005+ /* *
3006+ * @brief Create GstBuffer with data copied from input data pointer
3007+ */
3008+ static GstBuffer* CreateGstBufferWithData (gconstpointer data, gsize size)
3009+ {
3010+ GstBuffer *buffer = gst_buffer_new_and_alloc (size);
3011+ if (buffer)
3012+ {
3013+ GstMapInfo map;
3014+ gst_buffer_map (buffer, &map, GST_MAP_WRITE);
3015+ memcpy (map.data , data, size );
3016+ gst_buffer_unmap (buffer, &map);
3017+ }
3018+ return buffer;
3019+ }
3020+
29983021/* *
29993022 * @brief Inject stream buffer to gstreamer pipeline
30003023 */
@@ -3076,14 +3099,10 @@ bool InterfacePlayerRDK::SendHelper(int type, MediaSample sample, bool copy, boo
30763099
30773100 if (copy)
30783101 {
3079- buffer = gst_buffer_new_and_alloc ((guint) sample.dataSize );
3102+ buffer = CreateGstBufferWithData (sample. data , sample.dataSize );
30803103
30813104 if (buffer)
30823105 {
3083- GstMapInfo map;
3084- gst_buffer_map (buffer, &map, GST_MAP_WRITE);
3085- memcpy (map.data , sample.data , sample.dataSize );
3086- gst_buffer_unmap (buffer, &map);
30873106 GST_BUFFER_PTS (buffer) = pts;
30883107 GST_BUFFER_DTS (buffer) = dts;
30893108 GST_BUFFER_DURATION (buffer) = duration;
@@ -5296,6 +5315,11 @@ double InterfacePlayerRDK::FlushTrack(int mediaType, double pos, double audioDel
52965315 return rate;
52975316}
52985317
5318+ /* *
5319+ * @brief Sets the stream capabilities.
5320+ * @param[in] type The media type.
5321+ * @param[in] codecInfo The codec information.
5322+ */
52995323void InterfacePlayerRDK::SetStreamCaps (GstMediaType type, const CodecInfo &codecInfo)
53005324{
53015325 GstCaps *caps = GetCaps (codecInfo.codecFormat );
@@ -5374,19 +5398,11 @@ void InterfacePlayerRDK::SetStreamCaps(GstMediaType type, const CodecInfo &codec
53745398 }
53755399}
53765400
5377- static GstBuffer* CreateGstBufferWithData (gconstpointer data, gsize size)
5378- {
5379- GstBuffer *buffer = gst_buffer_new_and_alloc ( size );
5380- if (buffer)
5381- {
5382- GstMapInfo map;
5383- gst_buffer_map (buffer, &map, GST_MAP_WRITE);
5384- memcpy (map.data , data, size );
5385- gst_buffer_unmap (buffer, &map);
5386- }
5387- return buffer;
5388- }
5389-
5401+ /* *
5402+ * @brief Decorate a GstBuffer with DRM metadata
5403+ * @param[in] buffer The GstBuffer to decorate
5404+ * @param[in] drmMetadata The DRM metadata
5405+ */
53905406void DecorateGstBufferWithDrmMetadata (GstBuffer *buffer, const MediaDrmMetadata &drmMetadata)
53915407{
53925408 GstStructure *metadata = NULL ;
@@ -5397,8 +5413,6 @@ void DecorateGstBufferWithDrmMetadata(GstBuffer *buffer, const MediaDrmMetadata
53975413 " application/x-cenc" ,
53985414 " encrypted" , G_TYPE_BOOLEAN, TRUE ,
53995415 " kid" , GST_TYPE_BUFFER, kidBuffer,
5400- // TODO: deprecate original-media-type from drmMetadata
5401- // "original-media-type", G_TYPE_STRING, drmMetadata.originalMediaType.c_str(),
54025416 // TODO : cipher-mode to be added in caps and not drmMetadata
54035417 " cipher-mode" , G_TYPE_STRING, drmMetadata.cipher .c_str (),
54045418 NULL );
@@ -5446,9 +5460,10 @@ void DecorateGstBufferWithDrmMetadata(GstBuffer *buffer, const MediaDrmMetadata
54465460 }
54475461
54485462 if (metadata)
5449- { // serialize and print the metadata
5463+ {
5464+ // serialize and print the metadata
54505465 gchar *metaStr = gst_structure_to_string ( metadata );
5451- MW_LOG_INFO (" metadata: %s\n " , metaStr);
5466+ MW_LOG_INFO (" Added drm metadata: %s\n " , metaStr);
54525467 g_free (metaStr);
54535468
54545469 gst_buffer_add_protection_meta (buffer, metadata);
0 commit comments