mediafoundation: Port to C++

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1596>
This commit is contained in:
Seungha Yang 2022-01-24 02:41:29 +09:00
parent c7a9b5c458
commit 36020c7549
20 changed files with 332 additions and 360 deletions

View file

@ -84,7 +84,7 @@ typedef struct
} GstMFAacEncClassData;
/* *INDENT-ON* */
static GstElementClass *parent_class = NULL;
static GstElementClass *parent_class = nullptr;
static void gst_mf_aac_enc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
@ -210,7 +210,7 @@ gst_mf_aac_enc_get_output_type (GstMFAudioEnc * mfenc, GstAudioInfo * info,
{
GstMFAacEnc *self = (GstMFAacEnc *) mfenc;
GstMFTransform *transform = mfenc->transform;
GList *output_list = NULL;
GList *output_list = nullptr;
GList *iter;
ComPtr < IMFMediaType > target_output;
std::vector < ComPtr < IMFMediaType >> filtered_types;
@ -360,7 +360,7 @@ gst_mf_aac_enc_get_input_type (GstMFAudioEnc * mfenc, GstAudioInfo * info,
{
GstMFAacEnc *self = (GstMFAacEnc *) mfenc;
GstMFTransform *transform = mfenc->transform;
GList *input_list = NULL;
GList *input_list = nullptr;
GList *iter;
ComPtr < IMFMediaType > target_input;
std::vector < ComPtr < IMFMediaType >> filtered_types;
@ -438,7 +438,7 @@ gst_mf_aac_enc_set_src_caps (GstMFAudioEnc * mfenc, GstAudioInfo * info)
HRESULT hr;
GstCaps *src_caps;
GstBuffer *codec_data;
UINT8 *blob = NULL;
UINT8 *blob = nullptr;
UINT32 blob_size = 0;
gboolean ret;
ComPtr < IMFMediaType > output_type;
@ -481,7 +481,7 @@ gst_mf_aac_enc_set_src_caps (GstMFAudioEnc * mfenc, GstAudioInfo * info)
"channels", G_TYPE_INT, GST_AUDIO_INFO_CHANNELS (info),
"rate", G_TYPE_INT, GST_AUDIO_INFO_RATE (info),
"framed", G_TYPE_BOOLEAN, TRUE,
"codec_data", GST_TYPE_BUFFER, codec_data, NULL);
"codec_data", GST_TYPE_BUFFER, codec_data, nullptr);
gst_buffer_unref (codec_data);
gst_codec_utils_aac_caps_set_level_and_profile (src_caps,
@ -513,11 +513,11 @@ gst_mf_aac_enc_register (GstPlugin * plugin, guint rank,
gboolean is_default = TRUE;
GTypeInfo type_info = {
sizeof (GstMFAacEncClass),
NULL,
NULL,
nullptr,
nullptr,
(GClassInitFunc) gst_mf_aac_enc_class_init,
NULL,
NULL,
nullptr,
nullptr,
sizeof (GstMFAacEnc),
0,
(GInstanceInitFunc) gst_mf_aac_enc_init,
@ -566,10 +566,10 @@ gst_mf_aac_enc_plugin_init_internal (GstPlugin * plugin, guint rank,
{
HRESULT hr;
gint i;
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
gchar *device_name = NULL;
GList *output_list = NULL;
GstCaps *src_caps = nullptr;
GstCaps *sink_caps = nullptr;
gchar *device_name = nullptr;
GList *output_list = nullptr;
GList *iter;
std::set < UINT32 > channels_list;
std::set < UINT32 > rate_list;
@ -581,7 +581,7 @@ gst_mf_aac_enc_plugin_init_internal (GstPlugin * plugin, guint rank,
if (!gst_mf_transform_open (transform))
return;
g_object_get (transform, "device-name", &device_name, NULL);
g_object_get (transform, "device-name", &device_name, nullptr);
if (!device_name) {
GST_WARNING_OBJECT (transform, "Unknown device name");
return;

View file

@ -125,7 +125,7 @@ gst_mf_audio_enc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
return FALSE;
}
g_assert (klass->get_output_type != NULL);
g_assert (klass->get_output_type != nullptr);
if (!klass->get_output_type (self, info, &out_type)) {
GST_ERROR_OBJECT (self, "subclass failed to set output type");
return FALSE;
@ -138,7 +138,7 @@ gst_mf_audio_enc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
return FALSE;
}
g_assert (klass->get_input_type != NULL);
g_assert (klass->get_input_type != nullptr);
if (!klass->get_input_type (self, info, &in_type)) {
GST_ERROR_OBJECT (self, "subclass didn't provide input type");
return FALSE;
@ -151,7 +151,7 @@ gst_mf_audio_enc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
return FALSE;
}
g_assert (klass->set_src_caps != NULL);
g_assert (klass->set_src_caps != nullptr);
if (!klass->set_src_caps (self, info))
return FALSE;
@ -185,7 +185,7 @@ gst_mf_audio_enc_process_input (GstMFAudioEnc * self, GstBuffer * buffer)
if (!gst_buffer_map (buffer, &info, GST_MAP_READ)) {
GST_ELEMENT_ERROR (self,
RESOURCE, READ, ("Couldn't map input buffer"), (NULL));
RESOURCE, READ, ("Couldn't map input buffer"), (nullptr));
return FALSE;
}
@ -201,7 +201,7 @@ gst_mf_audio_enc_process_input (GstMFAudioEnc * self, GstBuffer * buffer)
if (!gst_mf_result (hr))
goto done;
hr = media_buffer->Lock (&data, NULL, NULL);
hr = media_buffer->Lock (&data, nullptr, nullptr);
if (!gst_mf_result (hr))
goto done;
@ -260,7 +260,7 @@ gst_mf_audio_enc_process_output (GstMFAudioEnc * self)
if (!gst_mf_result (hr))
return GST_FLOW_ERROR;
hr = media_buffer->Lock (&data, NULL, &buffer_len);
hr = media_buffer->Lock (&data, nullptr, &buffer_len);
if (!gst_mf_result (hr))
return GST_FLOW_ERROR;

View file

@ -36,14 +36,11 @@ using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Media::MediaProperties;
using namespace ABI::Windows::Graphics::Imaging;
using namespace ABI::Windows::Foundation;
G_BEGIN_DECLS
/* *INDENT-ON* */
GST_DEBUG_CATEGORY_EXTERN (gst_mf_source_object_debug);
#define GST_CAT_DEFAULT gst_mf_source_object_debug
G_END_DECLS
/* *INDENT-ON* */
enum
{
@ -250,7 +247,7 @@ gst_mf_capture_winrt_thread_func (GstMFCaptureWinRT * self)
idle_source = g_idle_source_new ();
g_source_set_callback (idle_source,
(GSourceFunc) gst_mf_capture_winrt_main_loop_running_cb, self, NULL);
(GSourceFunc) gst_mf_capture_winrt_main_loop_running_cb, self, nullptr);
g_source_attach (idle_source, self->context);
g_source_unref (idle_source);
@ -341,9 +338,9 @@ run_loop:
gst_mf_capture_winrt_stop (source);
delete self->capture;
self->capture = NULL;
self->capture = nullptr;
return NULL;
return nullptr;
}
static gboolean
@ -668,7 +665,7 @@ gst_mf_capture_winrt_get_caps (GstMFSourceObject * object)
if (self->supported_caps)
return gst_caps_ref (self->supported_caps);
return NULL;
return nullptr;
}
/* *INDENT-OFF* */
@ -678,7 +675,7 @@ gst_mf_capture_winrt_set_caps (GstMFSourceObject * object, GstCaps * caps)
GstMFCaptureWinRT *self = GST_MF_CAPTURE_WINRT (object);
std::vector<GstWinRTMediaDescription> desc_list;
HRESULT hr;
GstCaps *target_caps = NULL;
GstCaps *target_caps = nullptr;
hr = self->capture->GetAvailableDescriptions(desc_list);
if (!gst_mf_result (hr) || desc_list.empty()) {
@ -732,7 +729,7 @@ gst_mf_capture_winrt_new (GstMFSourceType type, gint device_index,
RoInitializeWrapper init_wrapper (RO_INIT_MULTITHREADED);
/* TODO: Add audio capture support */
g_return_val_if_fail (type == GST_MF_SOURCE_TYPE_VIDEO, NULL);
g_return_val_if_fail (type == GST_MF_SOURCE_TYPE_VIDEO, nullptr);
/* If application didn't pass ICoreDispatcher object,
* try to get dispatcher object for the current thread */
@ -752,7 +749,8 @@ gst_mf_capture_winrt_new (GstMFSourceType type, gint device_index,
self = (GstMFSourceObject *) g_object_new (GST_TYPE_MF_CAPTURE_WINRT,
"source-type", type, "device-index", device_index, "device-name",
device_name, "device-path", device_path, "dispatcher", dispatcher, NULL);
device_name, "device-path", device_path, "dispatcher", dispatcher,
nullptr);
/* Reset explicitly to ensure that it happens before
* RoInitializeWrapper dtor is called */
@ -761,7 +759,7 @@ gst_mf_capture_winrt_new (GstMFSourceType type, gint device_index,
if (!self->opened) {
GST_WARNING_OBJECT (self, "Couldn't open device");
gst_object_unref (self);
return NULL;
return nullptr;
}
gst_object_ref_sink (self);

View file

@ -43,6 +43,9 @@ DEFINE_GUID (GST_KSCATEGORY_CAPTURE, 0x65E8773DL, 0x8F56,
#if GST_MF_WINAPI_APP
#include <gst/winrt/gstwinrt.h>
/* *INDENT-OFF* */
using namespace ABI::Windows::Devices::Enumeration;
/* *INDENT-ON* */
#endif
GST_DEBUG_CATEGORY_EXTERN (gst_mf_debug);
@ -85,8 +88,9 @@ gst_mf_device_class_init (GstMFDeviceClass * klass)
g_object_class_install_property (gobject_class, PROP_DEVICE_PATH,
g_param_spec_string ("device-path", "Device Path",
"The device path", NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
"The device path", nullptr,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)));
}
static void
@ -112,7 +116,7 @@ gst_mf_device_create_element (GstDevice * device, const gchar * name)
elem = gst_element_factory_make ("mfvideosrc", name);
g_object_set (elem, "device-path", self->device_path, NULL);
g_object_set (elem, "device-path", self->device_path, nullptr);
return elem;
}
@ -181,16 +185,12 @@ static void gst_mf_device_provider_device_changed (GstWin32DeviceWatcher *
static gboolean gst_mf_device_provider_start_winrt (GstDeviceProvider * self);
static void
gst_mf_device_provider_device_added (GstWinRTDeviceWatcher * watcher,
__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformation * info,
gpointer user_data);
IDeviceInformation * info, gpointer user_data);
static void
gst_mf_device_provider_device_updated (GstWinRTDeviceWatcher * watcher,
__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate *
info_update, gpointer user_data);
IDeviceInformationUpdate * info_update, gpointer user_data);
static void gst_mf_device_provider_device_removed (GstWinRTDeviceWatcher *
watcher,
__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate *
info_update, gpointer user_data);
watcher, IDeviceInformationUpdate * info_update, gpointer user_data);
static void
gst_mf_device_provider_device_enum_completed (GstWinRTDeviceWatcher *
watcher, gpointer user_data);
@ -269,19 +269,19 @@ static GList *
gst_mf_device_provider_probe (GstDeviceProvider * provider)
{
GstMFDeviceProvider *self = GST_MF_DEVICE_PROVIDER (provider);
GList *list = NULL;
GList *list = nullptr;
gint i;
for (i = 0;; i++) {
GstMFSourceObject *obj = NULL;
GstMFSourceObject *obj = nullptr;
GstDevice *device;
GstStructure *props = NULL;
GstCaps *caps = NULL;
gchar *device_name = NULL;
gchar *device_path = NULL;
GstStructure *props = nullptr;
GstCaps *caps = nullptr;
gchar *device_name = nullptr;
gchar *device_path = nullptr;
obj = gst_mf_source_object_new (GST_MF_SOURCE_TYPE_VIDEO,
i, NULL, NULL, NULL);
i, nullptr, nullptr, nullptr);
if (!obj)
break;
@ -292,7 +292,7 @@ gst_mf_device_provider_probe (GstDeviceProvider * provider)
}
g_object_get (obj,
"device-path", &device_path, "device-name", &device_name, NULL);
"device-path", &device_path, "device-name", &device_name, nullptr);
if (!device_path) {
GST_WARNING_OBJECT (self, "Device path is unavailable");
@ -307,11 +307,12 @@ gst_mf_device_provider_probe (GstDeviceProvider * provider)
props = gst_structure_new ("mf-proplist",
"device.api", G_TYPE_STRING, "mediafoundation",
"device.path", G_TYPE_STRING, device_path,
"device.name", G_TYPE_STRING, device_name, NULL);
"device.name", G_TYPE_STRING, device_name, nullptr);
device = g_object_new (GST_TYPE_MF_DEVICE, "device-path", device_path,
device = (GstDevice *) g_object_new (GST_TYPE_MF_DEVICE,
"device-path", device_path,
"display-name", device_name, "caps", caps,
"device-class", "Source/Video", "properties", props, NULL);
"device-class", "Source/Video", "properties", props, nullptr);
list = g_list_append (list, device);
@ -334,7 +335,7 @@ gst_mf_device_provider_start_win32 (GstDeviceProvider * provider)
{
GstMFDeviceProvider *self = GST_MF_DEVICE_PROVIDER (provider);
GstWin32DeviceWatcher *watcher;
GList *devices = NULL;
GList *devices = nullptr;
GList *iter;
if (!GST_IS_WIN32_DEVICE_WATCHER (self->watcher))
@ -363,7 +364,7 @@ gst_mf_device_provider_start_winrt (GstDeviceProvider * provider)
{
GstMFDeviceProvider *self = GST_MF_DEVICE_PROVIDER (provider);
GstWinRTDeviceWatcher *watcher;
GList *devices = NULL;
GList *devices = nullptr;
GList *iter;
if (!GST_IS_WINRT_DEVICE_WATCHER (self->watcher))
@ -479,15 +480,15 @@ static void
gst_mf_device_provider_update_devices (GstMFDeviceProvider * self)
{
GstDeviceProvider *provider = GST_DEVICE_PROVIDER_CAST (self);
GList *prev_devices = NULL;
GList *new_devices = NULL;
GList *to_add = NULL;
GList *to_remove = NULL;
GList *prev_devices = nullptr;
GList *new_devices = nullptr;
GList *to_add = nullptr;
GList *to_remove = nullptr;
GList *iter;
GST_OBJECT_LOCK (self);
prev_devices = g_list_copy_deep (provider->devices,
(GCopyFunc) gst_object_ref, NULL);
(GCopyFunc) gst_object_ref, nullptr);
GST_OBJECT_UNLOCK (self);
new_devices = gst_mf_device_provider_probe (provider);
@ -544,8 +545,7 @@ gst_mf_device_provider_device_changed (GstWin32DeviceWatcher * watcher,
#if GST_MF_WINAPI_APP
static void
gst_mf_device_provider_device_added (GstWinRTDeviceWatcher * watcher,
__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformation * info,
gpointer user_data)
IDeviceInformation * info, gpointer user_data)
{
GstMFDeviceProvider *self = GST_MF_DEVICE_PROVIDER (user_data);
@ -555,8 +555,7 @@ gst_mf_device_provider_device_added (GstWinRTDeviceWatcher * watcher,
static void
gst_mf_device_provider_device_removed (GstWinRTDeviceWatcher * watcher,
__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate *
info_update, gpointer user_data)
IDeviceInformationUpdate * info_update, gpointer user_data)
{
GstMFDeviceProvider *self = GST_MF_DEVICE_PROVIDER (user_data);
@ -567,8 +566,7 @@ gst_mf_device_provider_device_removed (GstWinRTDeviceWatcher * watcher,
static void
gst_mf_device_provider_device_updated (GstWinRTDeviceWatcher * watcher,
__x_ABI_CWindows_CDevices_CEnumeration_CIDeviceInformationUpdate *
info_update, gpointer user_data)
IDeviceInformationUpdate * info_update, gpointer user_data)
{
GstMFDeviceProvider *self = GST_MF_DEVICE_PROVIDER (user_data);

View file

@ -75,7 +75,7 @@ gst_mf_h264_enc_rc_mode_get_type (void)
{GST_MF_H264_ENC_RC_MODE_UNCONSTRAINED_VBR,
"Unconstrained variable bitrate", "uvbr"},
{GST_MF_H264_ENC_RC_MODE_QUALITY, "Quality-based variable bitrate", "qvbr"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!rc_mode_type) {
@ -100,7 +100,7 @@ gst_mf_h264_enc_adaptive_mode_get_type (void)
{GST_MF_H264_ENC_ADAPTIVE_MODE_NONE, "None", "none"},
{GST_MF_H264_ENC_ADAPTIVE_MODE_FRAMERATE,
"Adaptively change the frame rate", "framerate"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!adaptive_mode_type) {
@ -127,7 +127,7 @@ gst_mf_h264_enc_content_type_get_type (void)
{GST_MF_H264_ENC_CONTENT_TYPE_UNKNOWN, "Unknown", "unknown"},
{GST_MF_H264_ENC_CONTENT_TYPE_FIXED_CAMERA_ANGLE,
"Fixed Camera Angle, such as a webcam", "fixed"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!content_type) {
@ -226,7 +226,7 @@ typedef struct _GstMFH264EncClass
GstMFVideoEncClass parent_class;
} GstMFH264EncClass;
static GstElementClass *parent_class = NULL;
static GstElementClass *parent_class = nullptr;
static void gst_mf_h264_enc_finalize (GObject * object);
static void gst_mf_h264_enc_get_property (GObject * object, guint prop_id,
@ -1036,7 +1036,7 @@ gst_mf_h264_enc_set_src_caps (GstMFVideoEnc * mfenc,
gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream",
"alignment", G_TYPE_STRING, "au", "profile",
G_TYPE_STRING, self->profile_str, NULL);
G_TYPE_STRING, self->profile_str, nullptr);
out_state = gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (self),
out_caps, state);
@ -1049,7 +1049,7 @@ gst_mf_h264_enc_set_src_caps (GstMFVideoEnc * mfenc,
tags = gst_tag_list_new_empty ();
gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_ENCODER,
gst_element_get_metadata (GST_ELEMENT_CAST (self),
GST_ELEMENT_METADATA_LONGNAME), NULL);
GST_ELEMENT_METADATA_LONGNAME), nullptr);
gst_video_encoder_merge_tags (GST_VIDEO_ENCODER (self), tags,
GST_TAG_MERGE_REPLACE);
gst_tag_list_unref (tags);
@ -1063,11 +1063,11 @@ gst_mf_h264_enc_plugin_init (GstPlugin * plugin, guint rank,
{
GTypeInfo type_info = {
sizeof (GstMFH264EncClass),
NULL,
NULL,
nullptr,
nullptr,
(GClassInitFunc) gst_mf_h264_enc_class_init,
NULL,
NULL,
nullptr,
nullptr,
sizeof (GstMFH264Enc),
0,
(GInstanceInitFunc) gst_mf_h264_enc_init,

View file

@ -62,7 +62,7 @@ gst_mf_h265_enc_rc_mode_get_type (void)
static const GEnumValue rc_mode_types[] = {
{GST_MF_H265_ENC_RC_MODE_CBR, "Constant bitrate", "cbr"},
{GST_MF_H265_ENC_RC_MODE_QUALITY, "Quality-based variable bitrate", "qvbr"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!rc_mode_type) {
@ -87,7 +87,7 @@ gst_mf_h265_enc_content_type_get_type (void)
{GST_MF_H265_ENC_CONTENT_TYPE_UNKNOWN, "Unknown", "unknown"},
{GST_MF_H265_ENC_CONTENT_TYPE_FIXED_CAMERA_ANGLE,
"Fixed Camera Angle, such as a webcam", "fixed"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!content_type) {
@ -171,7 +171,7 @@ typedef struct _GstMFH265EncClass
GstMFVideoEncClass parent_class;
} GstMFH265EncClass;
static GstElementClass *parent_class = NULL;
static GstElementClass *parent_class = nullptr;
static void gst_mf_h265_enc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
@ -774,13 +774,13 @@ gst_mf_h265_enc_set_src_caps (GstMFVideoEnc * mfenc,
s = gst_caps_get_structure (out_caps, 0);
gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream",
"alignment", G_TYPE_STRING, "au", NULL);
"alignment", G_TYPE_STRING, "au", nullptr);
if (GST_VIDEO_INFO_FORMAT (&mfenc->input_state->info) ==
GST_VIDEO_FORMAT_P010_10LE) {
gst_structure_set (s, "profile", G_TYPE_STRING, "main-10", NULL);
gst_structure_set (s, "profile", G_TYPE_STRING, "main-10", nullptr);
} else {
gst_structure_set (s, "profile", G_TYPE_STRING, "main", NULL);
gst_structure_set (s, "profile", G_TYPE_STRING, "main", nullptr);
}
out_state = gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (self),
@ -794,7 +794,7 @@ gst_mf_h265_enc_set_src_caps (GstMFVideoEnc * mfenc,
tags = gst_tag_list_new_empty ();
gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_ENCODER,
gst_element_get_metadata (GST_ELEMENT_CAST (self),
GST_ELEMENT_METADATA_LONGNAME), NULL);
GST_ELEMENT_METADATA_LONGNAME), nullptr);
gst_video_encoder_merge_tags (GST_VIDEO_ENCODER (self), tags,
GST_TAG_MERGE_REPLACE);
gst_tag_list_unref (tags);
@ -808,11 +808,11 @@ gst_mf_h265_enc_plugin_init (GstPlugin * plugin, guint rank,
{
GTypeInfo type_info = {
sizeof (GstMFH265EncClass),
NULL,
NULL,
nullptr,
nullptr,
(GClassInitFunc) gst_mf_h265_enc_class_init,
NULL,
NULL,
nullptr,
nullptr,
sizeof (GstMFH265Enc),
0,
(GInstanceInitFunc) gst_mf_h265_enc_init,

View file

@ -84,7 +84,7 @@ typedef struct
} GstMFMp3EncClassData;
/* *INDENT-ON* */
static GstElementClass *parent_class = NULL;
static GstElementClass *parent_class = nullptr;
static void gst_mf_mp3_enc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
@ -210,7 +210,7 @@ gst_mf_mp3_enc_get_output_type (GstMFAudioEnc * mfenc, GstAudioInfo * info,
{
GstMFMp3Enc *self = (GstMFMp3Enc *) mfenc;
GstMFTransform *transform = mfenc->transform;
GList *output_list = NULL;
GList *output_list = nullptr;
GList *iter;
ComPtr < IMFMediaType > target_output;
std::vector < ComPtr < IMFMediaType >> filtered_types;
@ -344,7 +344,7 @@ gst_mf_mp3_enc_get_input_type (GstMFAudioEnc * mfenc, GstAudioInfo * info,
{
GstMFMp3Enc *self = (GstMFMp3Enc *) mfenc;
GstMFTransform *transform = mfenc->transform;
GList *input_list = NULL;
GList *input_list = nullptr;
GList *iter;
ComPtr < IMFMediaType > target_input;
std::vector < ComPtr < IMFMediaType >> filtered_types;
@ -442,7 +442,7 @@ gst_mf_mp3_enc_set_src_caps (GstMFAudioEnc * mfenc, GstAudioInfo * info)
"mpegaudioversion", G_TYPE_INT, version,
"layer", G_TYPE_INT, 3,
"channels", G_TYPE_INT, GST_AUDIO_INFO_CHANNELS (info),
"rate", G_TYPE_INT, GST_AUDIO_INFO_RATE (info), NULL);
"rate", G_TYPE_INT, GST_AUDIO_INFO_RATE (info), nullptr);
ret =
gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (self), src_caps);
@ -469,11 +469,11 @@ gst_mf_mp3_enc_register (GstPlugin * plugin, guint rank,
gboolean is_default = TRUE;
GTypeInfo type_info = {
sizeof (GstMFMp3EncClass),
NULL,
NULL,
nullptr,
nullptr,
(GClassInitFunc) gst_mf_mp3_enc_class_init,
NULL,
NULL,
nullptr,
nullptr,
sizeof (GstMFMp3Enc),
0,
(GInstanceInitFunc) gst_mf_mp3_enc_init,
@ -520,8 +520,8 @@ static gboolean
gst_mf_mp3_enc_create_template_caps (const std::set < UINT32 > &rate_list,
gint channels, GstCaps ** sink_caps, GstCaps ** src_caps)
{
GstCaps *sink = NULL;
GstCaps *src = NULL;
GstCaps *sink = nullptr;
GstCaps *src = nullptr;
GValue rate_value = G_VALUE_INIT;
if (rate_list.empty ()) {
@ -538,8 +538,8 @@ gst_mf_mp3_enc_create_template_caps (const std::set < UINT32 > &rate_list,
gst_caps_from_string ("audio/mpeg, mpegversion = (int) 1,"
"layer = (int) 3");
gst_caps_set_simple (sink, "channels", G_TYPE_INT, channels, NULL);
gst_caps_set_simple (src, "channels", G_TYPE_INT, channels, NULL);
gst_caps_set_simple (sink, "channels", G_TYPE_INT, channels, nullptr);
gst_caps_set_simple (src, "channels", G_TYPE_INT, channels, nullptr);
} else {
sink =
gst_caps_from_string ("audio/x-raw, "
@ -567,12 +567,12 @@ gst_mf_mp3_enc_create_template_caps (const std::set < UINT32 > &rate_list,
g_value_unset (&rate_value);
if (*sink_caps == NULL)
if (*sink_caps == nullptr)
*sink_caps = sink;
else
*sink_caps = gst_caps_merge (*sink_caps, sink);
if (*src_caps == NULL)
if (*src_caps == nullptr)
*src_caps = src;
else
*src_caps = gst_caps_merge (*src_caps, src);
@ -586,10 +586,10 @@ gst_mf_mp3_enc_plugin_init_internal (GstPlugin * plugin, guint rank,
{
HRESULT hr;
gint i;
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
gchar *device_name = NULL;
GList *output_list = NULL;
GstCaps *src_caps = nullptr;
GstCaps *sink_caps = nullptr;
gchar *device_name = nullptr;
GList *output_list = nullptr;
GList *iter;
std::set < UINT32 > mono_rate_list;
std::set < UINT32 > stereo_rate_list;
@ -599,7 +599,7 @@ gst_mf_mp3_enc_plugin_init_internal (GstPlugin * plugin, guint rank,
if (!gst_mf_transform_open (transform))
return;
g_object_get (transform, "device-name", &device_name, NULL);
g_object_get (transform, "device-name", &device_name, nullptr);
if (!device_name) {
GST_WARNING_OBJECT (transform, "Unknown device name");
return;

View file

@ -25,14 +25,10 @@
#include "gstmfconfig.h"
#include <gmodule.h>
/* *INDENT-OFF* */
G_BEGIN_DECLS
GST_DEBUG_CATEGORY_EXTERN (gst_mf_debug);
#define GST_CAT_DEFAULT gst_mf_debug
G_END_DECLS
/* *INDENT-OFF* */
#define LOAD_SYMBOL(name,func) G_STMT_START { \
if (!g_module_symbol (module, G_STRINGIFY (name), (gpointer *) &vtable->func)) { \
GST_WARNING ("Failed to load '%s', %s", G_STRINGIFY (name), g_module_error()); \
@ -103,7 +99,7 @@ GstMFTEnum2 (GUID guidCategory, UINT32 Flags,
IMFAttributes * pAttributes, IMFActivate *** pppMFTActivate,
UINT32 * pnumMFTActivate)
{
g_assert (gst_mf_plat_vtable.GstMFTEnum2 != NULL);
g_assert (gst_mf_plat_vtable.GstMFTEnum2 != nullptr);
return gst_mf_plat_vtable.GstMFTEnum2 (guidCategory, Flags, pInputType,
pOutputType, pAttributes, pppMFTActivate, pnumMFTActivate);
@ -113,7 +109,7 @@ HRESULT __stdcall
GstMFCreateDXGIDeviceManager (UINT * resetToken,
IMFDXGIDeviceManager ** ppDeviceManager)
{
g_assert (gst_mf_plat_vtable.GstMFCreateDXGIDeviceManager != NULL);
g_assert (gst_mf_plat_vtable.GstMFCreateDXGIDeviceManager != nullptr);
return gst_mf_plat_vtable.GstMFCreateDXGIDeviceManager (resetToken,
ppDeviceManager);
@ -122,7 +118,7 @@ GstMFCreateDXGIDeviceManager (UINT * resetToken,
HRESULT __stdcall
GstMFCreateVideoSampleAllocatorEx (REFIID riid, void **ppSampleAllocator)
{
g_assert (gst_mf_plat_vtable.GstMFCreateVideoSampleAllocatorEx != NULL);
g_assert (gst_mf_plat_vtable.GstMFCreateVideoSampleAllocatorEx != nullptr);
return gst_mf_plat_vtable.GstMFCreateVideoSampleAllocatorEx (riid,
ppSampleAllocator);

View file

@ -45,8 +45,8 @@ enum
PROP_SOURCE_TYPE,
};
#define DEFAULT_DEVICE_PATH NULL
#define DEFAULT_DEVICE_NAME NULL
#define DEFAULT_DEVICE_PATH nullptr
#define DEFAULT_DEVICE_NAME nullptr
#define DEFAULT_DEVICE_INDEX -1
#define DEFAULT_SOURCE_TYPE GST_MF_SOURCE_TYPE_VIDEO
@ -57,7 +57,7 @@ gst_mf_source_type_get_type (void)
static const GEnumValue source_types[] = {
{GST_MF_SOURCE_TYPE_VIDEO, "Video", "video"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!source_type) {
@ -81,6 +81,9 @@ static void
gst_mf_source_object_class_init (GstMFSourceObjectClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamFlags flags =
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
gobject_class->finalize = gst_mf_source_object_finalize;
gobject_class->get_property = gst_mf_source_object_get_property;
@ -88,21 +91,17 @@ gst_mf_source_object_class_init (GstMFSourceObjectClass * klass)
g_object_class_install_property (gobject_class, PROP_DEVICE_PATH,
g_param_spec_string ("device-path", "Device Path",
"The device path", DEFAULT_DEVICE_PATH,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
"The device path", DEFAULT_DEVICE_PATH, flags));
g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
g_param_spec_string ("device-name", "Device Name",
"The human-readable device name", DEFAULT_DEVICE_NAME,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
"The human-readable device name", DEFAULT_DEVICE_NAME, flags));
g_object_class_install_property (gobject_class, PROP_DEVICE_INDEX,
g_param_spec_int ("device-index", "Device Index",
"The zero-based device index", -1, G_MAXINT, DEFAULT_DEVICE_INDEX,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
flags));
g_object_class_install_property (gobject_class, PROP_SOURCE_TYPE,
g_param_spec_enum ("source-type", "Source Type",
"Source Type", GST_TYPE_MF_SOURCE_TYPE,
DEFAULT_SOURCE_TYPE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
"Source Type", GST_TYPE_MF_SOURCE_TYPE, DEFAULT_SOURCE_TYPE, flags));
}
static void
@ -111,7 +110,7 @@ gst_mf_source_object_init (GstMFSourceObject * self)
self->device_index = DEFAULT_DEVICE_INDEX;
self->source_type = DEFAULT_SOURCE_TYPE;
g_weak_ref_init (&self->client, NULL);
g_weak_ref_init (&self->client, nullptr);
}
static void
@ -171,7 +170,7 @@ gst_mf_source_object_set_property (GObject * object, guint prop_id,
self->device_index = g_value_get_int (value);
break;
case PROP_SOURCE_TYPE:
self->source_type = g_value_get_enum (value);
self->source_type = (GstMFSourceType) g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -187,7 +186,7 @@ gst_mf_source_object_start (GstMFSourceObject * object)
g_return_val_if_fail (GST_IS_MF_SOURCE_OBJECT (object), FALSE);
klass = GST_MF_SOURCE_OBJECT_GET_CLASS (object);
g_assert (klass->start != NULL);
g_assert (klass->start != nullptr);
return klass->start (object);
}
@ -200,7 +199,7 @@ gst_mf_source_object_stop (GstMFSourceObject * object)
g_return_val_if_fail (GST_IS_MF_SOURCE_OBJECT (object), FALSE);
klass = GST_MF_SOURCE_OBJECT_GET_CLASS (object);
g_assert (klass->stop != NULL);
g_assert (klass->stop != nullptr);
return klass->stop (object);
}
@ -214,7 +213,7 @@ gst_mf_source_object_fill (GstMFSourceObject * object, GstBuffer * buffer)
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
klass = GST_MF_SOURCE_OBJECT_GET_CLASS (object);
g_assert (klass->fill != NULL);
g_assert (klass->fill != nullptr);
return klass->fill (object, buffer);
}
@ -225,10 +224,10 @@ gst_mf_source_object_create (GstMFSourceObject * object, GstBuffer ** buffer)
GstMFSourceObjectClass *klass;
g_return_val_if_fail (GST_IS_MF_SOURCE_OBJECT (object), GST_FLOW_ERROR);
g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (buffer != nullptr, GST_FLOW_ERROR);
klass = GST_MF_SOURCE_OBJECT_GET_CLASS (object);
g_assert (klass->create != NULL);
g_assert (klass->create != nullptr);
return klass->create (object, buffer);
}
@ -260,7 +259,7 @@ gst_mf_source_object_set_caps (GstMFSourceObject * object, GstCaps * caps)
g_return_val_if_fail (GST_IS_MF_SOURCE_OBJECT (object), FALSE);
klass = GST_MF_SOURCE_OBJECT_GET_CLASS (object);
g_assert (klass->set_caps != NULL);
g_assert (klass->set_caps != nullptr);
return klass->set_caps (object, caps);
}
@ -270,10 +269,10 @@ gst_mf_source_object_get_caps (GstMFSourceObject * object)
{
GstMFSourceObjectClass *klass;
g_return_val_if_fail (GST_IS_MF_SOURCE_OBJECT (object), NULL);
g_return_val_if_fail (GST_IS_MF_SOURCE_OBJECT (object), nullptr);
klass = GST_MF_SOURCE_OBJECT_GET_CLASS (object);
g_assert (klass->get_caps != NULL);
g_assert (klass->get_caps != nullptr);
return klass->get_caps (object);
}
@ -292,7 +291,7 @@ gst_mf_source_object_set_client (GstMFSourceObject * object,
GstClockTime
gst_mf_source_object_get_running_time (GstMFSourceObject * object)
{
GstElement *client = NULL;
GstElement *client = nullptr;
GstClockTime timestamp = GST_CLOCK_TIME_NONE;
g_return_val_if_fail (GST_IS_MF_SOURCE_OBJECT (object), GST_CLOCK_TIME_NONE);
@ -379,7 +378,7 @@ gst_mf_source_object_new (GstMFSourceType type, gint device_index,
#endif
g_assert_not_reached ();
return NULL;
return nullptr;
}
gint

View file

@ -33,15 +33,11 @@
/* *INDENT-OFF* */
using namespace Microsoft::WRL;
G_BEGIN_DECLS
/* *INDENT-ON* */
GST_DEBUG_CATEGORY_EXTERN (gst_mf_source_object_debug);
#define GST_CAT_DEFAULT gst_mf_source_object_debug
G_END_DECLS
/* *INDENT-ON* */
typedef struct _GstMFStreamMediaType
{
IMFMediaType *media_type;
@ -179,11 +175,11 @@ gst_mf_enum_media_type_from_source_reader (IMFSourceReader * source_reader,
{
gint i, j;
HRESULT hr;
GList *list = NULL;
GList *list = nullptr;
std::vector < std::string > unhandled_caps;
g_return_val_if_fail (source_reader != NULL, FALSE);
g_return_val_if_fail (media_types != NULL, FALSE);
g_return_val_if_fail (source_reader != nullptr, FALSE);
g_return_val_if_fail (media_types != nullptr, FALSE);
{
/* Retrive only the first video stream. non-first video stream might be
@ -200,7 +196,7 @@ gst_mf_enum_media_type_from_source_reader (IMFSourceReader * source_reader,
if (SUCCEEDED (hr)) {
GstMFStreamMediaType *mtype;
GstCaps *caps = NULL;
GstCaps *caps = nullptr;
GstStructure *s;
std::string name;
@ -257,7 +253,7 @@ done:
static void
gst_mf_stream_media_type_free (GstMFStreamMediaType * media_type)
{
g_return_if_fail (media_type != NULL);
g_return_if_fail (media_type != nullptr);
if (media_type->media_type)
media_type->media_type->Release ();
@ -342,24 +338,24 @@ gst_mf_source_reader_close (GstMFSourceReader * self)
if (self->activate) {
self->activate->ShutdownObject ();
self->activate->Release ();
self->activate = NULL;
self->activate = nullptr;
}
if (self->media_types) {
g_list_free_full (self->media_types,
(GDestroyNotify) gst_mf_stream_media_type_free);
self->media_types = NULL;
self->media_types = nullptr;
}
if (self->reader) {
self->reader->Release ();
self->reader = NULL;
self->reader = nullptr;
}
if (self->source) {
self->source->Shutdown ();
self->source->Release ();
self->source = NULL;
self->source = nullptr;
}
return TRUE;
@ -435,7 +431,7 @@ gst_mf_source_reader_start (GstMFSourceObject * object)
return FALSE;
hr = self->reader->SetCurrentMediaType (type->stream_index,
NULL, type->media_type);
nullptr, type->media_type);
if (!gst_mf_result (hr))
return FALSE;
@ -472,8 +468,8 @@ gst_mf_source_reader_read_sample (GstMFSourceReader * self)
IMFSample *sample = nullptr;
GstMFSourceReaderSample reader_sample;
hr = self->reader->ReadSample (type->stream_index, 0, NULL, &stream_flags,
NULL, &sample);
hr = self->reader->ReadSample (type->stream_index, 0, nullptr, &stream_flags,
nullptr, &sample);
if (!gst_mf_result (hr)) {
GST_ERROR_OBJECT (self, "Failed to read sample");
@ -584,7 +580,7 @@ gst_mf_source_reader_fill (GstMFSourceObject * object, GstBuffer * buffer)
if (ret != GST_FLOW_OK)
return ret;
hr = media_buffer->Lock (&data, NULL, NULL);
hr = media_buffer->Lock (&data, nullptr, nullptr);
if (!gst_mf_result (hr)) {
GST_ERROR_OBJECT (self, "Failed to lock media buffer");
return GST_FLOW_ERROR;
@ -672,7 +668,7 @@ gst_mf_source_reader_create (GstMFSourceObject * object, GstBuffer ** buffer)
if (ret != GST_FLOW_OK)
return ret;
hr = media_buffer->Lock (&data, NULL, &len);
hr = media_buffer->Lock (&data, nullptr, &len);
if (!gst_mf_result (hr) || len == 0) {
GST_ERROR_OBJECT (self, "Failed to lock media buffer");
return GST_FLOW_ERROR;
@ -733,7 +729,7 @@ gst_mf_source_reader_get_caps (GstMFSourceObject * object)
if (self->supported_caps)
return gst_caps_ref (self->supported_caps);
return NULL;
return nullptr;
}
static gboolean
@ -741,7 +737,7 @@ gst_mf_source_reader_set_caps (GstMFSourceObject * object, GstCaps * caps)
{
GstMFSourceReader *self = GST_MF_SOURCE_READER (object);
GList *iter;
GstMFStreamMediaType *best_type = NULL;
GstMFStreamMediaType *best_type = nullptr;
for (iter = self->media_types; iter; iter = g_list_next (iter)) {
GstMFStreamMediaType *minfo = (GstMFStreamMediaType *) iter->data;
@ -782,17 +778,17 @@ gst_mf_source_reader_thread_func (GstMFSourceReader * self)
{
GstMFSourceObject *object = GST_MF_SOURCE_OBJECT (self);
GSource *source;
GList *activate_list = NULL;
GstMFDeviceActivate *target = NULL;
GList *activate_list = nullptr;
GstMFDeviceActivate *target = nullptr;
GList *iter;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
CoInitializeEx (nullptr, COINIT_MULTITHREADED);
g_main_context_push_thread_default (self->context);
source = g_idle_source_new ();
g_source_set_callback (source,
(GSourceFunc) gst_mf_source_reader_main_loop_running_cb, self, NULL);
(GSourceFunc) gst_mf_source_reader_main_loop_running_cb, self, nullptr);
g_source_attach (source, self->context);
g_source_unref (source);
@ -865,7 +861,7 @@ run_loop:
CoUninitialize ();
return NULL;
return nullptr;
}
static gboolean
@ -873,9 +869,9 @@ gst_mf_source_enum_device_activate (GstMFSourceReader * self,
GstMFSourceType source_type, GList ** device_sources)
{
HRESULT hr;
GList *ret = NULL;
GList *ret = nullptr;
ComPtr < IMFAttributes > attr;
IMFActivate **devices = NULL;
IMFActivate **devices = nullptr;
UINT32 i, count = 0;
hr = MFCreateAttributes (&attr, 1);
@ -923,7 +919,7 @@ gst_mf_source_enum_device_activate (GstMFSourceReader * self,
if (gst_mf_result (hr)) {
entry->path = g_utf16_to_utf8 ((const gunichar2 *) name,
-1, NULL, NULL, NULL);
-1, nullptr, nullptr, nullptr);
CoTaskMemFree (name);
}
@ -931,7 +927,7 @@ gst_mf_source_enum_device_activate (GstMFSourceReader * self,
&name, &name_len);
if (gst_mf_result (hr)) {
entry->name = g_utf16_to_utf8 ((const gunichar2 *) name,
-1, NULL, NULL, NULL);
-1, nullptr, nullptr, nullptr);
CoTaskMemFree (name);
}
@ -950,7 +946,7 @@ done:
static void
gst_mf_device_activate_free (GstMFDeviceActivate * activate)
{
g_return_if_fail (activate != NULL);
g_return_if_fail (activate != nullptr);
if (activate->handle)
activate->handle->Release ();
@ -980,18 +976,18 @@ gst_mf_source_reader_new (GstMFSourceType type, gint device_index,
GstMFSourceObject *self;
/* TODO: add more type */
g_return_val_if_fail (type == GST_MF_SOURCE_TYPE_VIDEO, NULL);
g_return_val_if_fail (type == GST_MF_SOURCE_TYPE_VIDEO, nullptr);
self = (GstMFSourceObject *) g_object_new (GST_TYPE_MF_SOURCE_READER,
"source-type", type, "device-index", device_index, "device-name",
device_name, "device-path", device_path, NULL);
device_name, "device-path", device_path, nullptr);
gst_object_ref_sink (self);
if (!self->opened) {
GST_WARNING_OBJECT (self, "Couldn't open device");
gst_object_unref (self);
return NULL;
return nullptr;
}
return self;

View file

@ -34,13 +34,9 @@
/* *INDENT-OFF* */
using namespace Microsoft::WRL;
G_BEGIN_DECLS
GST_DEBUG_CATEGORY_EXTERN (gst_mf_transform_debug);
#define GST_CAT_DEFAULT gst_mf_transform_debug
G_END_DECLS
typedef HRESULT (*GstMFTransformAsyncCallbackOnEvent) (MediaEventType event,
GstObject * client);
@ -187,7 +183,7 @@ private:
: ref_count_ (1)
, running_ (false)
{
g_weak_ref_init (&client_, NULL);
g_weak_ref_init (&client_, nullptr);
}
~GstMFTransformAsyncCallback ()
@ -295,7 +291,7 @@ gst_mf_transform_class_init (GstMFTransformClass * klass)
g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
g_param_spec_string ("device-name", "device-name",
"Device name", NULL,
"Device name", nullptr,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_HARDWARE,
g_param_spec_boolean ("hardware", "Hardware",
@ -346,10 +342,10 @@ static void
gst_mf_transform_clear_enum_params (GstMFTransformEnumParams * params)
{
g_free (params->input_typeinfo);
params->input_typeinfo = NULL;
params->input_typeinfo = nullptr;
g_free (params->output_typeinfo);
params->output_typeinfo = NULL;
params->output_typeinfo = nullptr;
}
static void
@ -454,18 +450,18 @@ static gpointer
gst_mf_transform_thread_func (GstMFTransform * self)
{
HRESULT hr = S_OK;
IMFActivate **devices = NULL;
IMFActivate **devices = nullptr;
UINT32 num_devices, i;
LPWSTR name = NULL;
LPWSTR name = nullptr;
GSource *source;
CoInitializeEx (NULL, COINIT_MULTITHREADED);
CoInitializeEx (nullptr, COINIT_MULTITHREADED);
g_main_context_push_thread_default (self->context);
source = g_idle_source_new ();
g_source_set_callback (source,
(GSourceFunc) gst_mf_transform_main_loop_running_cb, self, NULL);
(GSourceFunc) gst_mf_transform_main_loop_running_cb, self, nullptr);
g_source_attach (source, self->context);
g_source_unref (source);
@ -529,11 +525,11 @@ gst_mf_transform_thread_func (GstMFTransform * self)
devices[i]->Release ();
hr = self->activate->GetAllocatedString (MFT_FRIENDLY_NAME_Attribute,
&name, NULL);
&name, nullptr);
if (gst_mf_result (hr)) {
self->device_name = g_utf16_to_utf8 ((const gunichar2 *) name,
-1, NULL, NULL, NULL);
-1, nullptr, nullptr, nullptr);
GST_INFO_OBJECT (self, "Open device %s", self->device_name);
CoTaskMemFree (name);
@ -556,12 +552,12 @@ run_loop:
if (self->activate) {
self->activate->Release ();
self->activate = NULL;
self->activate = nullptr;
}
CoUninitialize ();
return NULL;
return nullptr;
}
static GstFlowReturn
@ -692,7 +688,7 @@ gst_mf_transform_process_input (GstMFTransform * object, IMFSample * sample)
gboolean ret = FALSE;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (sample != NULL, FALSE);
g_return_val_if_fail (sample != nullptr, FALSE);
GST_TRACE_OBJECT (object, "Process input");
@ -759,7 +755,7 @@ gst_mf_transform_get_output (GstMFTransform * object, IMFSample ** sample)
GstFlowReturn ret;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), GST_FLOW_ERROR);
g_return_val_if_fail (sample != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (sample != nullptr, GST_FLOW_ERROR);
/* Hardware MFT must not call this method, instead client must install
* new sample callback so that outputting data from Media Foundation's
* worker thread */
@ -942,7 +938,7 @@ gst_mf_transform_open (GstMFTransform * object)
GstMFTransformOpenData data;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (object->activate != NULL, FALSE);
g_return_val_if_fail (object->activate != nullptr, FALSE);
data.object = object;
data.invoked = FALSE;
@ -1011,12 +1007,12 @@ gst_mf_transform_close (GstMFTransform * object)
if (object->codec_api) {
object->codec_api->Release ();
object->codec_api = NULL;
object->codec_api = nullptr;
}
if (object->transform) {
object->transform->Release ();
object->transform = NULL;
object->transform = nullptr;
}
return TRUE;
@ -1075,7 +1071,7 @@ gst_mf_transform_on_event (MediaEventType event, GstMFTransform * self)
IMFActivate *
gst_mf_transform_get_activate_handle (GstMFTransform * object)
{
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), NULL);
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), nullptr);
return object->activate;
}
@ -1083,12 +1079,12 @@ gst_mf_transform_get_activate_handle (GstMFTransform * object)
IMFTransform *
gst_mf_transform_get_transform_handle (GstMFTransform * object)
{
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), NULL);
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), nullptr);
if (!object->transform) {
GST_WARNING_OBJECT (object,
"IMFTransform is not configured, open MFT first");
return NULL;
return nullptr;
}
return object->transform;
@ -1097,11 +1093,11 @@ gst_mf_transform_get_transform_handle (GstMFTransform * object)
ICodecAPI *
gst_mf_transform_get_codec_api_handle (GstMFTransform * object)
{
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), NULL);
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), nullptr);
if (!object->codec_api) {
GST_WARNING_OBJECT (object, "ICodecAPI is not configured, open MFT first");
return NULL;
return nullptr;
}
return object->codec_api;
@ -1114,10 +1110,10 @@ gst_mf_transform_get_input_available_types (GstMFTransform * object,
IMFTransform *transform;
HRESULT hr;
DWORD index = 0;
GList *list = NULL;
GList *list = nullptr;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (input_types != NULL, FALSE);
g_return_val_if_fail (input_types != nullptr, FALSE);
transform = object->transform;
@ -1127,7 +1123,7 @@ gst_mf_transform_get_input_available_types (GstMFTransform * object,
}
do {
IMFMediaType *type = NULL;
IMFMediaType *type = nullptr;
hr = transform->GetInputAvailableType (object->input_id, index, &type);
if (SUCCEEDED (hr))
@ -1148,10 +1144,10 @@ gst_mf_transform_get_output_available_types (GstMFTransform * object,
IMFTransform *transform;
HRESULT hr;
DWORD index = 0;
GList *list = NULL;
GList *list = nullptr;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (output_types != NULL, FALSE);
g_return_val_if_fail (output_types != nullptr, FALSE);
transform = object->transform;
@ -1230,7 +1226,7 @@ gst_mf_transform_get_input_current_type (GstMFTransform * object,
HRESULT hr;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (input_type != NULL, FALSE);
g_return_val_if_fail (input_type != nullptr, FALSE);
transform = object->transform;
@ -1255,7 +1251,7 @@ gst_mf_transform_get_output_current_type (GstMFTransform * object,
HRESULT hr;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (output_type != NULL, FALSE);
g_return_val_if_fail (output_type != nullptr, FALSE);
transform = object->transform;
@ -1277,14 +1273,14 @@ gst_mf_transform_new (GstMFTransformEnumParams * params)
{
GstMFTransform *self;
g_return_val_if_fail (params != NULL, NULL);
g_return_val_if_fail (params != nullptr, nullptr);
self = (GstMFTransform *) g_object_new (GST_TYPE_MF_TRANSFORM_OBJECT,
"enum-params", params, NULL);
"enum-params", params, nullptr);
if (!self->initialized) {
gst_object_unref (self);
return NULL;
return nullptr;
}
gst_object_ref_sink (self);
@ -1300,7 +1296,7 @@ gst_mf_transform_set_codec_api_uint32 (GstMFTransform * object,
VARIANT var;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (api != NULL, FALSE);
g_return_val_if_fail (api != nullptr, FALSE);
if (!object->codec_api) {
GST_WARNING_OBJECT (object, "codec api unavailable");
@ -1325,7 +1321,7 @@ gst_mf_transform_set_codec_api_uint64 (GstMFTransform * object,
VARIANT var;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (api != NULL, FALSE);
g_return_val_if_fail (api != nullptr, FALSE);
if (!object->codec_api) {
GST_WARNING_OBJECT (object, "codec api unavailable");
@ -1350,7 +1346,7 @@ gst_mf_transform_set_codec_api_boolean (GstMFTransform * object,
VARIANT var;
g_return_val_if_fail (GST_IS_MF_TRANSFORM (object), FALSE);
g_return_val_if_fail (api != NULL, FALSE);
g_return_val_if_fail (api != nullptr, FALSE);
if (!object->codec_api) {
GST_WARNING_OBJECT (object, "codec api unavailable");

View file

@ -30,13 +30,9 @@
/* *INDENT-OFF* */
using namespace Microsoft::WRL;
G_BEGIN_DECLS
GST_DEBUG_CATEGORY_EXTERN (gst_mf_utils_debug);
#define GST_CAT_DEFAULT gst_mf_utils_debug
G_END_DECLS
#define MAKE_RAW_FORMAT_CAPS(format) \
"video/x-raw, format = (string) " format
@ -116,14 +112,14 @@ gst_mf_video_subtype_from_video_format (GstVideoFormat format)
return &raw_video_format_map[i].mf_format;
}
return NULL;
return nullptr;
}
static GstCaps *
gst_mf_media_type_to_video_caps (IMFMediaType * media_type)
{
HRESULT hr;
GstCaps *caps = NULL;
GstCaps *caps = nullptr;
gint i;
guint32 width = 0;
guint32 height = 0;
@ -138,7 +134,7 @@ gst_mf_media_type_to_video_caps (IMFMediaType * media_type)
hr = media_type->GetGUID (MF_MT_SUBTYPE, &subtype);
if (FAILED (hr)) {
GST_WARNING ("Failed to get subtype, hr: 0x%x", (guint) hr);
return NULL;
return nullptr;
}
for (i = 0; i < G_N_ELEMENTS (raw_video_format_map); i++) {
@ -161,7 +157,7 @@ gst_mf_media_type_to_video_caps (IMFMediaType * media_type)
if (!caps) {
GST_WARNING ("Unknown format %" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (subtype.Data1));
return NULL;
return nullptr;
}
hr = MFGetAttributeSize (media_type, MF_MT_FRAME_SIZE, &width, &height);
@ -170,23 +166,24 @@ gst_mf_media_type_to_video_caps (IMFMediaType * media_type)
if (raw_format) {
gst_caps_unref (caps);
return NULL;
return nullptr;
}
}
if (width > 0 && height > 0) {
gst_caps_set_simple (caps, "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, NULL);
"height", G_TYPE_INT, height, nullptr);
}
hr = MFGetAttributeRatio (media_type, MF_MT_FRAME_RATE, &num, &den);
if (SUCCEEDED (hr) && num > 0 && den > 0)
gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, num, den, NULL);
gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, num, den,
nullptr);
hr = MFGetAttributeRatio (media_type, MF_MT_PIXEL_ASPECT_RATIO, &num, &den);
if (SUCCEEDED (hr) && num > 0 && den > 0)
gst_caps_set_simple (caps,
"pixel-aspect-ratio", GST_TYPE_FRACTION, num, den, NULL);
"pixel-aspect-ratio", GST_TYPE_FRACTION, num, den, nullptr);
colorimetry.range = GST_VIDEO_COLOR_RANGE_UNKNOWN;
colorimetry.matrix = GST_VIDEO_COLOR_MATRIX_UNKNOWN;
@ -311,9 +308,9 @@ gst_mf_media_type_to_video_caps (IMFMediaType * media_type)
str = gst_video_colorimetry_to_string (&colorimetry);
if (str) {
gst_caps_set_simple (caps, "colorimetry", G_TYPE_STRING, str, NULL);
gst_caps_set_simple (caps, "colorimetry", G_TYPE_STRING, str, nullptr);
g_free (str);
str = NULL;
str = nullptr;
}
chroma_site = GST_VIDEO_CHROMA_SITE_UNKNOWN;
@ -341,7 +338,7 @@ gst_mf_media_type_to_video_caps (IMFMediaType * media_type)
if (chroma_site != GST_VIDEO_CHROMA_SITE_UNKNOWN)
gst_caps_set_simple (caps, "chroma-site", G_TYPE_STRING,
gst_video_chroma_to_string (chroma_site), NULL);
gst_video_chroma_to_string (chroma_site), nullptr);
return caps;
}
@ -352,18 +349,18 @@ gst_mf_media_type_to_caps (IMFMediaType * media_type)
GUID major_type;
HRESULT hr;
g_return_val_if_fail (media_type != NULL, NULL);
g_return_val_if_fail (media_type != nullptr, nullptr);
hr = media_type->GetMajorType (&major_type);
if (FAILED (hr)) {
GST_WARNING ("failed to get major type, hr: 0x%x", (guint) hr);
return NULL;
return nullptr;
}
if (IsEqualGUID (major_type, MFMediaType_Video))
return gst_mf_media_type_to_video_caps (media_type);
return NULL;
return nullptr;
}
void
@ -480,14 +477,14 @@ _gst_mf_result (HRESULT hr, GstDebugCategory * cat, const gchar * file,
gboolean ret = TRUE;
if (FAILED (hr)) {
gchar *error_text = NULL;
gchar *error_text = nullptr;
error_text = g_win32_error_message ((gint) hr);
/* g_win32_error_message() doesn't cover all HERESULT return code,
* so it could be empty string, or null if there was an error
* in g_utf16_to_utf8() */
gst_debug_log (cat, GST_LEVEL_WARNING, file, function, line,
NULL, "MediaFoundation call failed: 0x%x, %s", (guint) hr,
nullptr, "MediaFoundation call failed: 0x%x, %s", (guint) hr,
GST_STR_NULL (error_text));
g_free (error_text);
@ -675,16 +672,16 @@ gst_mf_guid_to_static_string (const GUID & guid)
GST_MF_IF_EQUAL_RETURN (guid, MF_MT_ORIGINAL_WAVE_FORMAT_TAG);
#endif
return NULL;
return nullptr;
}
static gchar *
gst_mf_guid_to_string (const GUID & guid)
{
const gchar *str = NULL;
const gchar *str = nullptr;
HRESULT hr;
WCHAR *name = NULL;
gchar *ret = NULL;
WCHAR *name = nullptr;
gchar *ret = nullptr;
str = gst_mf_guid_to_static_string (guid);
if (str)
@ -692,7 +689,9 @@ gst_mf_guid_to_string (const GUID & guid)
hr = StringFromCLSID (guid, &name);
if (gst_mf_result (hr) && name) {
ret = g_utf16_to_utf8 ((const gunichar2 *) name, -1, NULL, NULL, NULL);
ret =
g_utf16_to_utf8 ((const gunichar2 *) name, -1, nullptr, nullptr,
nullptr);
CoTaskMemFree (name);
if (ret)
@ -740,14 +739,14 @@ gst_mf_attribute_value_to_string (const GUID & guid, const PROPVARIANT & var)
return gst_mf_guid_to_string (*var.puuid);
case VT_LPWSTR:
return g_utf16_to_utf8 ((const gunichar2 *) var.pwszVal,
-1, NULL, NULL, NULL);
-1, nullptr, nullptr, nullptr);
case VT_UNKNOWN:
return g_strdup ("IUnknown");
default:
return g_strdup_printf ("Unhandled type (vt = %d)", var.vt);
}
return NULL;
return nullptr;
}
static void
@ -755,8 +754,8 @@ gst_mf_dump_attribute_value_by_index (IMFAttributes * attr, const gchar * msg,
guint index, GstDebugLevel level, GstDebugCategory * cat,
const gchar * file, const gchar * function, gint line)
{
gchar *guid_name = NULL;
gchar *value = NULL;
gchar *guid_name = nullptr;
gchar *value = nullptr;
GUID guid = GUID_NULL;
HRESULT hr;
@ -776,7 +775,8 @@ gst_mf_dump_attribute_value_by_index (IMFAttributes * attr, const gchar * msg,
goto done;
gst_debug_log (cat, level, file, function, line,
NULL, "%s attribute %d, %s: %s", msg ? msg : "", index, guid_name, value);
nullptr, "%s attribute %d, %s: %s", msg ? msg : "", index, guid_name,
value);
done:
PropVariantClear (&var);

View file

@ -20,14 +20,10 @@
#include "gstmfvideobuffer.h"
#include <string.h>
/* *INDENT-OFF* */
G_BEGIN_DECLS
GST_DEBUG_CATEGORY_EXTERN (gst_mf_video_buffer_debug);
#define GST_CAT_DEFAULT gst_mf_video_buffer_debug
G_END_DECLS
/* *INDENT-OFF* */
IGstMFVideoBuffer::IGstMFVideoBuffer ()
: ref_count_ (1)
, current_len_ (0)
@ -241,7 +237,7 @@ IGstMFVideoBuffer::QueryInterface (REFIID riid, void ** object)
GST_TRACE ("query IGstMFVideoBuffer interface %p", this);
*object = this;
} else {
*object = NULL;
*object = nullptr;
return E_NOINTERFACE;
}

View file

@ -36,15 +36,11 @@
/* *INDENT-OFF* */
using namespace Microsoft::WRL;
G_BEGIN_DECLS
/* *INDENT-ON* */
GST_DEBUG_CATEGORY_EXTERN (gst_mf_video_enc_debug);
#define GST_CAT_DEFAULT gst_mf_video_enc_debug
G_END_DECLS
/* *INDENT-ON* */
#define gst_mf_video_enc_parent_class parent_class
G_DEFINE_ABSTRACT_TYPE (GstMFVideoEnc, gst_mf_video_enc,
GST_TYPE_VIDEO_ENCODER);
@ -168,7 +164,8 @@ gst_mf_video_enc_open (GstVideoEncoder * enc)
device = self->d3d11_device;
hr = GstMFCreateDXGIDeviceManager (&self->reset_token, &self->device_manager);
hr = GstMFCreateDXGIDeviceManager (&self->reset_token,
&self->device_manager);
if (!gst_mf_result (hr)) {
GST_ERROR_OBJECT (self, "Couldn't create DXGI device manager");
gst_clear_object (&self->other_d3d11_device);
@ -249,7 +246,7 @@ gst_mf_video_enc_close (GstVideoEncoder * enc)
if (self->input_state) {
gst_video_codec_state_unref (self->input_state);
self->input_state = NULL;
self->input_state = nullptr;
}
#if GST_MF_HAVE_D3D11
if (self->device_manager) {
@ -260,7 +257,7 @@ gst_mf_video_enc_close (GstVideoEncoder * enc)
if (self->mf_allocator) {
self->mf_allocator->UninitializeSampleAllocator ();
self->mf_allocator->Release ();
self->mf_allocator = NULL;
self->mf_allocator = nullptr;
}
gst_clear_object (&self->other_d3d11_device);
@ -288,7 +285,7 @@ gst_mf_video_enc_set_format (GstVideoEncoder * enc, GstVideoCodecState * state)
GstVideoInfo *info = &state->info;
ComPtr < IMFMediaType > in_type;
ComPtr < IMFMediaType > out_type;
GList *input_types = NULL;
GList *input_types = nullptr;
GList *iter;
HRESULT hr;
gint fps_n, fps_d;
@ -454,7 +451,7 @@ gst_mf_video_enc_set_format (GstVideoEncoder * enc, GstVideoCodecState * state)
return FALSE;
}
g_assert (klass->set_src_caps != NULL);
g_assert (klass->set_src_caps != nullptr);
if (!klass->set_src_caps (self, self->input_state, out_type.Get ())) {
GST_ERROR_OBJECT (self, "subclass couldn't set src caps");
return FALSE;
@ -463,7 +460,7 @@ gst_mf_video_enc_set_format (GstVideoEncoder * enc, GstVideoCodecState * state)
if (self->mf_allocator) {
self->mf_allocator->UninitializeSampleAllocator ();
self->mf_allocator->Release ();
self->mf_allocator = NULL;
self->mf_allocator = nullptr;
}
/* Check whether upstream is d3d11 element */
@ -644,7 +641,7 @@ gst_mf_video_enc_process_input (GstMFVideoEnc * self,
GstMFVideoEncClass *klass = GST_MF_VIDEO_ENC_GET_CLASS (self);
HRESULT hr;
gboolean unset_force_keyframe = FALSE;
GstMFVideoEncFrameData *frame_data = NULL;
GstMFVideoEncFrameData *frame_data = nullptr;
gboolean res;
frame_data = g_new0 (GstMFVideoEncFrameData, 1);
@ -702,8 +699,8 @@ static GstVideoCodecFrame *
gst_mf_video_enc_find_output_frame (GstMFVideoEnc * self, LONGLONG mf_pts)
{
GList *l, *walk = gst_video_encoder_get_frames (GST_VIDEO_ENCODER (self));
GstVideoCodecFrame *ret = NULL;
GstVideoCodecFrame *closest = NULL;
GstVideoCodecFrame *ret = nullptr;
GstVideoCodecFrame *closest = nullptr;
LONGLONG min_pts_abs_diff = 0;
for (l = walk; l; l = l->next) {
@ -769,11 +766,11 @@ gst_mf_video_enc_finish_sample (GstMFVideoEnc * self, IMFSample * sample)
if (!gst_mf_result (hr))
goto done;
hr = media_buffer->Lock (&data, NULL, &buffer_len);
hr = media_buffer->Lock (&data, nullptr, &buffer_len);
if (!gst_mf_result (hr))
goto done;
buffer = gst_buffer_new_allocate (NULL, buffer_len, NULL);
buffer = gst_buffer_new_allocate (nullptr, buffer_len, nullptr);
gst_buffer_fill (buffer, 0, data, buffer_len);
media_buffer->Unlock ();
@ -934,8 +931,8 @@ gst_mf_video_enc_create_input_sample (GstMFVideoEnc * self,
ComPtr < IGstMFVideoBuffer > video_buffer;
GstVideoInfo *info = &self->input_state->info;
gint i, j;
GstVideoFrame *vframe = NULL;
BYTE *data = NULL;
GstVideoFrame *vframe = nullptr;
BYTE *data = nullptr;
gboolean need_copy;
vframe = g_new0 (GstVideoFrame, 1);
@ -970,7 +967,7 @@ gst_mf_video_enc_create_input_sample (GstMFVideoEnc * self,
if (!gst_mf_result (hr))
goto error;
} else {
hr = media_buffer->Lock (&data, NULL, NULL);
hr = media_buffer->Lock (&data, nullptr, nullptr);
if (!gst_mf_result (hr))
goto error;
@ -1016,7 +1013,7 @@ gst_mf_video_enc_create_input_sample (GstMFVideoEnc * self,
} else {
gst_video_frame_unmap (vframe);
g_free (vframe);
vframe = NULL;
vframe = nullptr;
}
*sample = new_sample.Detach ();
@ -1293,14 +1290,14 @@ gst_mf_video_enc_propose_allocation (GstVideoEncoder * enc, GstQuery * query)
#if GST_MF_HAVE_D3D11
GstMFVideoEnc *self = GST_MF_VIDEO_ENC (enc);
GstVideoInfo info;
GstBufferPool *pool = NULL;
GstBufferPool *pool = nullptr;
GstCaps *caps;
guint size;
GstD3D11Device *device = self->other_d3d11_device;
gst_query_parse_allocation (query, &caps, NULL);
gst_query_parse_allocation (query, &caps, nullptr);
if (caps == NULL)
if (caps == nullptr)
return FALSE;
if (!gst_video_info_from_caps (&info, caps))
@ -1337,7 +1334,7 @@ gst_mf_video_enc_propose_allocation (GstVideoEncoder * enc, GstQuery * query)
gboolean is_hardware = FALSE;
gint i;
g_object_get (device, "hardware", &is_hardware, NULL);
g_object_get (device, "hardware", &is_hardware, nullptr);
/* In case of hardware, set D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX flag
* so that it can be shared with other d3d11 devices */
@ -1377,7 +1374,7 @@ gst_mf_video_enc_propose_allocation (GstVideoEncoder * enc, GstQuery * query)
gst_object_unref (pool);
}
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, nullptr);
return TRUE;
@ -1467,16 +1464,16 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
MFT_REGISTER_TYPE_INFO *infos;
UINT32 info_size;
gint i;
GstCaps *src_caps = NULL;
GstCaps *sink_caps = NULL;
GstCaps *d3d11_caps = NULL;
GValue *supported_formats = NULL;
GValue *profiles = NULL;
GstCaps *src_caps = nullptr;
GstCaps *sink_caps = nullptr;
GstCaps *d3d11_caps = nullptr;
GValue *supported_formats = nullptr;
GValue *profiles = nullptr;
gboolean have_I420 = FALSE;
gboolean have_NV12 = FALSE;
gboolean have_P010 = FALSE;
gboolean d3d11_aware = FALSE;
gchar *device_name = NULL;
gchar *device_name = nullptr;
IMFActivate *activate;
IMFTransform *encoder;
ICodecAPI *codec_api;
@ -1485,20 +1482,20 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
{eAVEncH264VProfile_High, "high"},
{eAVEncH264VProfile_Main, "main"},
{eAVEncH264VProfile_Base, "baseline"},
{0, NULL},
{0, nullptr},
};
GstMFVideoEncProfileMap hevc_profile_map[] = {
{eAVEncH265VProfile_Main_420_8, "main"},
{eAVEncH265VProfile_Main_420_10, "main-10"},
{0, NULL},
{0, nullptr},
};
GstMFVideoEncProfileMap *profile_to_check = NULL;
GstMFVideoEncProfileMap *profile_to_check = nullptr;
static const gchar *h264_caps_str =
"video/x-h264, stream-format=(string) byte-stream, alignment=(string) au";
static const gchar *hevc_caps_str =
"video/x-h265, stream-format=(string) byte-stream, alignment=(string) au";
static const gchar *vp9_caps_str = "video/x-vp9";
const gchar *codec_caps_str = NULL;
const gchar *codec_caps_str = nullptr;
/* NOTE: depending on environment,
* some enumerated h/w MFT might not be usable (e.g., multiple GPU case) */
@ -1523,7 +1520,7 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
return;
}
g_object_get (transform, "device-name", &device_name, NULL);
g_object_get (transform, "device-name", &device_name, nullptr);
if (!device_name) {
GST_WARNING_OBJECT (transform, "Unknown device name");
return;
@ -1639,7 +1636,7 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
if (mf_profile == 0)
break;
g_assert (profile_str != NULL);
g_assert (profile_str != nullptr);
hr = out_type->SetUINT32 (MF_MT_MPEG2_PROFILE, mf_profile);
if (!gst_mf_result (hr))
@ -1683,15 +1680,15 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
* API for querying supported max resolution... */
gst_caps_set_simple (sink_caps,
"width", GST_TYPE_INT_RANGE, 64, 8192,
"height", GST_TYPE_INT_RANGE, 64, 8192, NULL);
"height", GST_TYPE_INT_RANGE, 64, 8192, nullptr);
gst_caps_set_simple (src_caps,
"width", GST_TYPE_INT_RANGE, 64, 8192,
"height", GST_TYPE_INT_RANGE, 64, 8192, NULL);
"height", GST_TYPE_INT_RANGE, 64, 8192, nullptr);
#if GST_MF_HAVE_D3D11
/* Check whether this MFT can support D3D11 */
if (d3d11_device && (have_NV12 || have_P010)) {
g_object_get (transform, "d3d11-aware", &d3d11_aware, NULL);
g_object_get (transform, "d3d11-aware", &d3d11_aware, nullptr);
GST_DEBUG_OBJECT (transform, "d3d11 aware %d", d3d11_aware);
}
@ -1699,7 +1696,7 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID & subtype,
gint64 adapter_luid = 0;
GValue d3d11_formats = G_VALUE_INIT;
g_object_get (d3d11_device, "adapter-luid", &adapter_luid, NULL);
g_object_get (d3d11_device, "adapter-luid", &adapter_luid, nullptr);
d3d11_caps = gst_caps_copy (sink_caps);
@ -1797,8 +1794,8 @@ gst_mf_video_enc_enum (guint enum_flags, GUID * subtype, guint device_index,
GstMFTransform *transform;
gint64 adapter_luid = 0;
*sink_template = NULL;
*src_template = NULL;
*sink_template = nullptr;
*src_template = nullptr;
memset (device_caps, 0, sizeof (GstMFVideoEncDeviceCaps));
if (!IsEqualGUID (MFVideoFormat_H264, *subtype) &&
@ -1806,14 +1803,14 @@ gst_mf_video_enc_enum (guint enum_flags, GUID * subtype, guint device_index,
!IsEqualGUID (MFVideoFormat_VP90, *subtype)) {
GST_ERROR ("Unknown subtype GUID");
return NULL;
return nullptr;
}
if (d3d11_device) {
g_object_get (d3d11_device, "adapter-luid", &adapter_luid, NULL);
g_object_get (d3d11_device, "adapter-luid", &adapter_luid, nullptr);
if (!adapter_luid) {
GST_ERROR ("Couldn't get adapter LUID");
return NULL;
return nullptr;
}
}
@ -1828,7 +1825,7 @@ gst_mf_video_enc_enum (guint enum_flags, GUID * subtype, guint device_index,
transform = gst_mf_transform_new (&enum_params);
if (!transform)
return NULL;
return nullptr;
gst_mf_video_enc_enum_internal (transform, output_type.guidSubtype,
d3d11_device, device_caps, sink_template, src_template);
@ -1850,9 +1847,9 @@ gst_mf_video_enc_register_internal (GstPlugin * plugin, guint rank,
gint i;
GstMFVideoEncClassData *cdata;
gboolean is_default = TRUE;
gchar *device_name = NULL;
const gchar *type_name_prefix = NULL;
const gchar *feature_name_prefix = NULL;
gchar *device_name = nullptr;
const gchar *type_name_prefix = nullptr;
const gchar *feature_name_prefix = nullptr;
if (IsEqualGUID (MFVideoFormat_H264, *subtype)) {
type_name_prefix = "H264";
@ -1869,8 +1866,8 @@ gst_mf_video_enc_register_internal (GstPlugin * plugin, guint rank,
}
/* Must be checked already */
g_object_get (transform, "device-name", &device_name, NULL);
g_assert (device_name != NULL);
g_object_get (transform, "device-name", &device_name, nullptr);
g_assert (device_name != nullptr);
cdata = g_new0 (GstMFVideoEncClassData, 1);
cdata->sink_caps = gst_caps_copy (sink_caps);
@ -1925,9 +1922,9 @@ void
gst_mf_video_enc_register (GstPlugin * plugin, guint rank, GUID * subtype,
GTypeInfo * type_info, GList * d3d11_device)
{
GstMFTransform *transform = NULL;
GstCaps *sink_template = NULL;
GstCaps *src_template = NULL;
GstMFTransform *transform = nullptr;
GstCaps *sink_template = nullptr;
GstCaps *src_template = nullptr;
guint enum_flags;
GstMFVideoEncDeviceCaps device_caps;
guint i;
@ -1964,7 +1961,7 @@ gst_mf_video_enc_register (GstPlugin * plugin, guint rank, GUID * subtype,
/* AMD seems to be able to support up to 12 GPUs */
for (i = 0; i < 12; i++) {
transform = gst_mf_video_enc_enum (enum_flags, subtype, i, &device_caps,
NULL, &sink_template, &src_template);
nullptr, &sink_template, &src_template);
/* No more MFT to enumerate */
if (!transform)
@ -1989,7 +1986,7 @@ gst_mf_video_enc_register (GstPlugin * plugin, guint rank, GUID * subtype,
MFT_ENUM_FLAG_SORTANDFILTER | MFT_ENUM_FLAG_SORTANDFILTER_APPROVED_ONLY);
transform = gst_mf_video_enc_enum (enum_flags, subtype, 0, &device_caps,
NULL, &sink_template, &src_template);
nullptr, &sink_template, &src_template);
if (!transform)
goto done;

View file

@ -92,8 +92,8 @@ enum
PROP_DISPATCHER,
};
#define DEFAULT_DEVICE_PATH NULL
#define DEFAULT_DEVICE_NAME NULL
#define DEFAULT_DEVICE_PATH nullptr
#define DEFAULT_DEVICE_NAME nullptr
#define DEFAULT_DEVICE_INDEX -1
static void gst_mf_video_src_finalize (GObject * object);
@ -124,6 +124,8 @@ gst_mf_video_src_class_init (GstMFVideoSrcClass * klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstBaseSrcClass *basesrc_class = GST_BASE_SRC_CLASS (klass);
GstPushSrcClass *pushsrc_class = GST_PUSH_SRC_CLASS (klass);
GParamFlags flags = (GParamFlags) (G_PARAM_READWRITE |
GST_PARAM_MUTABLE_READY | G_PARAM_STATIC_STRINGS);
gobject_class->finalize = gst_mf_video_src_finalize;
gobject_class->get_property = gst_mf_video_src_get_property;
@ -131,19 +133,14 @@ gst_mf_video_src_class_init (GstMFVideoSrcClass * klass)
g_object_class_install_property (gobject_class, PROP_DEVICE_PATH,
g_param_spec_string ("device-path", "Device Path",
"The device path", DEFAULT_DEVICE_PATH,
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
G_PARAM_STATIC_STRINGS));
"The device path", DEFAULT_DEVICE_PATH, flags));
g_object_class_install_property (gobject_class, PROP_DEVICE_NAME,
g_param_spec_string ("device-name", "Device Name",
"The human-readable device name", DEFAULT_DEVICE_NAME,
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
G_PARAM_STATIC_STRINGS));
"The human-readable device name", DEFAULT_DEVICE_NAME, flags));
g_object_class_install_property (gobject_class, PROP_DEVICE_INDEX,
g_param_spec_int ("device-index", "Device Index",
"The zero-based device index", -1, G_MAXINT, DEFAULT_DEVICE_INDEX,
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
G_PARAM_STATIC_STRINGS));
flags));
#if GST_MF_WINAPI_APP
/**
* GstMFVideoSrc:dispatcher:
@ -160,8 +157,9 @@ gst_mf_video_src_class_init (GstMFVideoSrcClass * klass)
"the reference count of given ICoreDispatcher and release it after "
"use. Therefore, caller does not need to consider additional "
"reference count management",
GST_PARAM_CONDITIONALLY_AVAILABLE | GST_PARAM_MUTABLE_READY |
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
(GParamFlags) (GST_PARAM_CONDITIONALLY_AVAILABLE |
GST_PARAM_MUTABLE_READY | G_PARAM_WRITABLE |
G_PARAM_STATIC_STRINGS)));
#endif
gst_element_class_set_static_metadata (element_class,
@ -266,7 +264,7 @@ gst_mf_video_src_start (GstBaseSrc * src)
GST_DEBUG_OBJECT (self, "Start");
self->source = gst_mf_source_object_new (GST_MF_SOURCE_TYPE_VIDEO,
self->device_index, self->device_name, self->device_path, NULL);
self->device_index, self->device_name, self->device_path, nullptr);
self->n_frames = 0;
self->latency = 0;
@ -291,7 +289,7 @@ gst_mf_video_src_stop (GstBaseSrc * src)
if (self->source) {
gst_mf_source_object_stop (self->source);
gst_object_unref (self->source);
self->source = NULL;
self->source = nullptr;
}
self->started = FALSE;
@ -327,7 +325,7 @@ static GstCaps *
gst_mf_video_src_get_caps (GstBaseSrc * src, GstCaps * filter)
{
GstMFVideoSrc *self = GST_MF_VIDEO_SRC (src);
GstCaps *caps = NULL;
GstCaps *caps = nullptr;
if (self->source)
caps = gst_mf_source_object_get_caps (self->source);
@ -416,7 +414,7 @@ gst_mf_video_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
{
GstMFVideoSrc *self = GST_MF_VIDEO_SRC (pushsrc);
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *buf = NULL;
GstBuffer *buf = nullptr;
GstClock *clock;
GstClockTime running_time = GST_CLOCK_TIME_NONE;
GstClockTimeDiff diff;

View file

@ -61,7 +61,7 @@ gst_mf_vp9_enc_rc_mode_get_type (void)
static const GEnumValue rc_mode_types[] = {
{GST_MF_VP9_ENC_RC_MODE_CBR, "Constant bitrate", "cbr"},
{GST_MF_VP9_ENC_RC_MODE_QUALITY, "Quality-based variable bitrate", "qvbr"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!rc_mode_type) {
@ -86,7 +86,7 @@ gst_mf_vp9_enc_content_type_get_type (void)
{GST_MF_VP9_ENC_CONTENT_TYPE_UNKNOWN, "Unknown", "unknown"},
{GST_MF_VP9_ENC_CONTENT_TYPE_FIXED_CAMERA_ANGLE,
"Fixed Camera Angle, such as a webcam", "fixed"},
{0, NULL, NULL}
{0, nullptr, nullptr}
};
if (!content_type) {
@ -142,7 +142,7 @@ typedef struct _GstMFVP9EncClass
GstMFVideoEncClass parent_class;
} GstMFVP9EncClass;
static GstElementClass *parent_class = NULL;
static GstElementClass *parent_class = nullptr;
static void gst_mf_vp9_enc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
@ -559,7 +559,7 @@ gst_mf_vp9_enc_set_src_caps (GstMFVideoEnc * mfenc,
tags = gst_tag_list_new_empty ();
gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_ENCODER,
gst_element_get_metadata (GST_ELEMENT_CAST (self),
GST_ELEMENT_METADATA_LONGNAME), NULL);
GST_ELEMENT_METADATA_LONGNAME), nullptr);
gst_video_encoder_merge_tags (GST_VIDEO_ENCODER (self), tags,
GST_TAG_MERGE_REPLACE);
gst_tag_list_unref (tags);
@ -573,11 +573,11 @@ gst_mf_vp9_enc_plugin_init (GstPlugin * plugin, guint rank,
{
GTypeInfo type_info = {
sizeof (GstMFVP9EncClass),
NULL,
NULL,
nullptr,
nullptr,
(GClassInitFunc) gst_mf_vp9_enc_class_init,
NULL,
NULL,
nullptr,
nullptr,
sizeof (GstMFVP9Enc),
0,
(GInstanceInitFunc) gst_mf_vp9_enc_init,

View file

@ -119,7 +119,7 @@ gst_win32_device_watcher_finalize (GObject * object)
static LRESULT CALLBACK
window_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
GstWin32DeviceWatcher * self;
GstWin32DeviceWatcher *self;
switch (msg) {
case WM_CREATE:
@ -154,7 +154,7 @@ create_hwnd (GstWin32DeviceWatcher * self)
{
WNDCLASSEXA wc;
ATOM atom = 0;
HINSTANCE hinstance = GetModuleHandle (NULL);
HINSTANCE hinstance = GetModuleHandle (nullptr);
static const gchar *klass_name = "GstWin32DeviceWatcher";
HWND hwnd;
@ -174,7 +174,7 @@ create_hwnd (GstWin32DeviceWatcher * self)
G_UNLOCK (create_lock);
GST_ERROR_OBJECT (self, "Failed to register window class, lastError 0x%x",
(guint) GetLastError ());
return NULL;
return nullptr;
}
} else {
GST_LOG_OBJECT (self, "window class was already registered");
@ -182,7 +182,7 @@ create_hwnd (GstWin32DeviceWatcher * self)
G_UNLOCK (create_lock);
hwnd = CreateWindowExA (0, klass_name, "", 0, 0, 0, 0, 0,
HWND_MESSAGE, NULL, hinstance, self);
HWND_MESSAGE, nullptr, hinstance, self);
if (!hwnd) {
GST_ERROR_OBJECT (self, "Failed to create window handle, lastError 0x%x",
(guint) GetLastError ());
@ -207,7 +207,7 @@ win32_msg_cb (GIOChannel * source, GIOCondition condition, gpointer data)
{
MSG msg;
if (!PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
if (!PeekMessage (&msg, nullptr, 0, 0, PM_REMOVE))
return G_SOURCE_CONTINUE;
TranslateMessage (&msg);
@ -299,7 +299,7 @@ gst_win32_device_watcher_new (DWORD device_type, const GUID * class_guid,
typedef struct
{
GstWin32DeviceWatcher * self;
GstWin32DeviceWatcher *self;
gboolean handled;
gboolean ret;
@ -308,7 +308,7 @@ typedef struct
static gboolean
register_device_notification (DeviceNotificationData * data)
{
GstWin32DeviceWatcher * self = data->self;
GstWin32DeviceWatcher *self = data->self;
DEV_BROADCAST_DEVICEINTERFACE di = { 0, };
if (self->device_notify)
@ -357,7 +357,7 @@ gst_win32_device_watcher_start (GstWin32DeviceWatcher * watcher)
static gboolean
unregister_device_notification (DeviceNotificationData * data)
{
GstWin32DeviceWatcher * self = data->self;
GstWin32DeviceWatcher *self = data->self;
if (!self->device_notify)
goto out;

View file

@ -40,13 +40,9 @@ using namespace ABI::Windows::Foundation::Collections;
using namespace ABI::Windows::Media::Devices;
using namespace ABI::Windows::Media::MediaProperties;
G_BEGIN_DECLS
GST_DEBUG_CATEGORY_EXTERN (gst_mf_source_object_debug);
#define GST_CAT_DEFAULT gst_mf_source_object_debug
G_END_DECLS
static std::string
convert_hstring_to_string (HString * hstr)
{
@ -187,11 +183,11 @@ GstWinRTMediaDescription::Fill(HString &source_id,
caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, format.c_str(), "width", G_TYPE_INT, width,
"height", G_TYPE_INT, height, NULL);
"height", G_TYPE_INT, height, nullptr);
if (fps_n > 0 && fps_d > 0)
gst_caps_set_simple (caps,
"framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
"framerate", GST_TYPE_FRACTION, fps_n, fps_d, nullptr);
source_id.CopyTo (source_id_.GetAddressOf());
hstr_subtype.CopyTo (subtype_.GetAddressOf());

View file

@ -1,19 +1,19 @@
mf_sources = [
'plugin.c',
'gstmfutils.cpp',
'gstmftransform.cpp',
'gstmfvideoenc.cpp',
'gstmfh264enc.cpp',
'gstmfh265enc.cpp',
'gstmfvp9enc.cpp',
'gstmfvideosrc.c',
'gstmfsourceobject.c',
'gstmfdevice.c',
'gstmfvideosrc.cpp',
'gstmfsourceobject.cpp',
'gstmfdevice.cpp',
'gstmfaudioenc.cpp',
'gstmfaacenc.cpp',
'gstmfmp3enc.cpp',
'gstmfvideobuffer.cpp',
'gstmfplatloader.c',
'gstmfplatloader.cpp',
'plugin.cpp',
]
mf_desktop_sources = [

View file

@ -60,6 +60,7 @@
#include "gstmfconfig.h"
#include <winapifamily.h>
#include <wrl.h>
#include <gst/gst.h>
#include <gst/video/video.h>
@ -86,6 +87,10 @@ GST_DEBUG_CATEGORY (gst_mf_video_enc_debug);
#define GST_CAT_DEFAULT gst_mf_debug
/* *INDENT-OFF* */
using namespace Microsoft::WRL;
/* *INDENT-ON* */
static void
plugin_deinit (gpointer data)
{
@ -96,19 +101,17 @@ plugin_deinit (gpointer data)
static GList *
get_d3d11_devices (void)
{
GList *ret = NULL;
GList *ret = nullptr;
guint i;
HRESULT hr;
IMFVideoSampleAllocatorEx *allocator = NULL;
ComPtr < IMFVideoSampleAllocatorEx > allocator;
/* Check whether we can use IMFVideoSampleAllocatorEx interface */
hr = GstMFCreateVideoSampleAllocatorEx (&IID_IMFVideoSampleAllocatorEx,
hr = GstMFCreateVideoSampleAllocatorEx (IID_IMFVideoSampleAllocatorEx,
&allocator);
if (!gst_mf_result (hr)) {
GST_DEBUG ("IMFVideoSampleAllocatorEx interface is unavailable");
return NULL;
} else {
IMFVideoSampleAllocatorEx_Release (allocator);
return nullptr;
}
/* AMD seems supporting up to 12 cards, and 8 for NVIDIA */
@ -125,7 +128,7 @@ get_d3d11_devices (void)
if (!device)
break;
g_object_get (device, "hardware", &is_hardware, NULL);
g_object_get (device, "hardware", &is_hardware, nullptr);
if (!is_hardware) {
GST_DEBUG_OBJECT (device, "Given d3d11 device is not for hardware");
@ -152,8 +155,8 @@ get_d3d11_devices (void)
* MF specific texture pool without download texture */
device_handle = gst_d3d11_device_get_device_handle (device);
hr = ID3D11Device_CheckFeatureSupport (device_handle,
D3D11_FEATURE_D3D11_OPTIONS4, &options, sizeof (options));
hr = device_handle->CheckFeatureSupport (D3D11_FEATURE_D3D11_OPTIONS4,
&options, sizeof (options));
if (!gst_d3d11_result (hr, device) ||
!options.ExtendedNV12SharedTextureSupported) {
GST_DEBUG_OBJECT (device,
@ -163,8 +166,7 @@ get_d3d11_devices (void)
}
/* can we bind NV12 texture for encoder? */
hr = ID3D11Device_CheckFormatSupport (device_handle,
DXGI_FORMAT_NV12, &supported);
hr = device_handle->CheckFormatSupport (DXGI_FORMAT_NV12, &supported);
if (!gst_d3d11_result (hr, device)) {
GST_DEBUG_OBJECT (device, "Couldn't query format support");
@ -187,8 +189,8 @@ static gboolean
plugin_init (GstPlugin * plugin)
{
HRESULT hr;
GstRank rank = GST_RANK_SECONDARY;
GList *device_list = NULL;
guint rank = GST_RANK_SECONDARY;
GList *device_list = nullptr;
GST_DEBUG_CATEGORY_INIT (gst_mf_debug, "mf", 0, "media foundation");
GST_DEBUG_CATEGORY_INIT (gst_mf_utils_debug,
@ -244,7 +246,7 @@ plugin_init (GstPlugin * plugin)
* of each MFStartup and MFShutdown call should be identical. This rule is
* simliar to that of CoInitialize/CoUninitialize pair */
g_object_set_data_full (G_OBJECT (plugin),
"plugin-mediafoundation-shutdown", "shutdown-data",
"plugin-mediafoundation-shutdown", (gpointer) "shutdown-data",
(GDestroyNotify) plugin_deinit);
return TRUE;