Commit 5ba24bc7 authored by Matthias Klumpp's avatar Matthias Klumpp
Browse files

Rename AsVideoCodec/Container to AsVideo*Kind for consistency

Also, this avoids an API break if we ever need an AsVideoCodec class in
future.
parent adc0deb8
......@@ -85,22 +85,22 @@ _AsVideo * AppStream::Video::asVideo() const
Video::CodecKind Video::codec() const
{
return Video::CodecKind(as_video_get_codec(d->m_vid));
return Video::CodecKind(as_video_get_codec_kind(d->m_vid));
}
void Video::setCodec(Video::CodecKind codec)
{
as_video_set_codec(d->m_vid, (AsVideoCodec) codec);
as_video_set_codec_kind(d->m_vid, (AsVideoCodecKind) codec);
}
Video::ContainerKind Video::container() const
{
return Video::ContainerKind(as_video_get_container(d->m_vid));
return Video::ContainerKind(as_video_get_container_kind(d->m_vid));
}
void Video::setContainer(Video::ContainerKind container)
{
as_video_set_container(d->m_vid, (AsVideoContainer) container);
as_video_set_container_kind(d->m_vid, (AsVideoContainerKind) container);
}
uint Video::height() const
......
......@@ -942,8 +942,8 @@ as_validator_check_screenshots (AsValidator *validator, xmlNode *node, AsCompone
if (codec_str == NULL) {
as_validator_add_issue (validator, iter2, "screenshot-video-codec-missing", NULL);
} else {
AsVideoCodec codec = as_video_codec_from_string (codec_str);
if (codec == AS_VIDEO_CODEC_UNKNOWN)
AsVideoCodecKind codec = as_video_codec_kind_from_string (codec_str);
if (codec == AS_VIDEO_CODEC_KIND_UNKNOWN)
as_validator_add_issue (validator, iter2, "screenshot-video-codec-invalid", codec_str);
}
......@@ -951,8 +951,8 @@ as_validator_check_screenshots (AsValidator *validator, xmlNode *node, AsCompone
if (container_str == NULL) {
as_validator_add_issue (validator, iter2, "screenshot-video-container-missing", NULL);
} else {
AsVideoContainer container = as_video_container_from_string (container_str);
if (container == AS_VIDEO_CONTAINER_UNKNOWN)
AsVideoContainerKind container = as_video_container_kind_from_string (container_str);
if (container == AS_VIDEO_CONTAINER_KIND_UNKNOWN)
as_validator_add_issue (validator, iter2, "screenshot-video-container-invalid", container_str);
}
......
......@@ -34,8 +34,8 @@
typedef struct
{
AsVideoCodec codec;
AsVideoContainer container;
AsVideoCodecKind codec;
AsVideoContainerKind container;
gchar *url;
guint width;
......@@ -70,27 +70,27 @@ as_video_init (AsVideo *video)
}
/**
* as_video_codec_from_string:
* @codec: the string.
* as_video_codec_kind_from_string:
* @str: the string.
*
* Converts the text representation to an enumerated value.
*
* Returns: (transfer full): a #AsVideoCodec, or %AS_VIDEO_CODEC_UNKNOWN for unknown.
* Returns: (transfer full): a #AsVideoCodecKind, or %AS_VIDEO_CODEC_KIND_UNKNOWN for unknown.
*
**/
AsVideoCodec
as_video_codec_from_string (const gchar *codec)
AsVideoCodecKind
as_video_codec_kind_from_string (const gchar *str)
{
if (g_strcmp0 (codec, "av1") == 0)
return AS_VIDEO_CODEC_AV1;
if (g_strcmp0 (codec, "vp9") == 0)
return AS_VIDEO_CODEC_VP9;
return AS_VIDEO_CODEC_UNKNOWN;
if (g_strcmp0 (str, "av1") == 0)
return AS_VIDEO_CODEC_KIND_AV1;
if (g_strcmp0 (str, "vp9") == 0)
return AS_VIDEO_CODEC_KIND_VP9;
return AS_VIDEO_CODEC_KIND_UNKNOWN;
}
/**
* as_video_codec_to_string:
* @codec: the #AsVideoCodec.
* as_video_codec_kind_to_string:
* @kind: the #AsVideoCodecKind.
*
* Converts the enumerated value to an text representation.
*
......@@ -98,37 +98,37 @@ as_video_codec_from_string (const gchar *codec)
*
**/
const gchar*
as_video_codec_to_string (AsVideoCodec codec)
as_video_codec_kind_to_string (AsVideoCodecKind kind)
{
if (codec == AS_VIDEO_CODEC_AV1)
if (kind == AS_VIDEO_CODEC_KIND_AV1)
return "av1";
if (codec == AS_VIDEO_CODEC_VP9)
if (kind == AS_VIDEO_CODEC_KIND_VP9)
return "vp9";
return NULL;
}
/**
* as_video_container_from_string:
* @container: the string.
* as_video_container_kind_from_string:
* @str: the string.
*
* Converts the text representation to an enumerated value.
*
* Returns: (transfer full): a #AsVideoContainer, or %AS_VIDEO_CONTAINER_UNKNOWN for unknown.
* Returns: (transfer full): a #AsVideoContainerKind, or %AS_VIDEO_CONTAINER_KIND_UNKNOWN for unknown.
*
**/
AsVideoContainer
as_video_container_from_string (const gchar *container)
AsVideoContainerKind
as_video_container_kind_from_string (const gchar *str)
{
if (g_strcmp0 (container, "mkv") == 0)
return AS_VIDEO_CONTAINER_MKV;
if (g_strcmp0 (container, "webm") == 0)
return AS_VIDEO_CONTAINER_WEBM;
return AS_VIDEO_CONTAINER_UNKNOWN;
if (g_strcmp0 (str, "mkv") == 0)
return AS_VIDEO_CONTAINER_KIND_MKV;
if (g_strcmp0 (str, "webm") == 0)
return AS_VIDEO_CONTAINER_KIND_WEBM;
return AS_VIDEO_CONTAINER_KIND_UNKNOWN;
}
/**
* as_video_container_to_string:
* @container: the #AsVideoContainer.
* as_video_container_kind_to_string:
* @kind: the #AsVideoContainerKind.
*
* Converts the enumerated value to an text representation.
*
......@@ -136,72 +136,72 @@ as_video_container_from_string (const gchar *container)
*
**/
const gchar*
as_video_container_to_string (AsVideoContainer container)
as_video_container_kind_to_string (AsVideoContainerKind kind)
{
if (container == AS_VIDEO_CONTAINER_MKV)
if (kind == AS_VIDEO_CONTAINER_KIND_MKV)
return "mkv";
if (container == AS_VIDEO_CONTAINER_WEBM)
if (kind == AS_VIDEO_CONTAINER_KIND_WEBM)
return "webm";
return NULL;
}
/**
* as_video_set_codec:
* as_video_set_codec_kind:
* @video: a #AsVideo instance.
* @codec: the #AsVideoCodec, e.g. %AS_VIDEO_CODEC_AV1.
* @kind: the #AsVideoCodecKind, e.g. %AS_VIDEO_CODEC_KIND_AV1.
*
* Sets the video codec.
*
**/
void
as_video_set_codec (AsVideo *video, AsVideoCodec codec)
as_video_set_codec_kind (AsVideo *video, AsVideoCodecKind kind)
{
AsVideoPrivate *priv = GET_PRIVATE (video);
priv->codec = codec;
priv->codec = kind;
}
/**
* as_video_get_codec:
* as_video_get_codec_kind:
* @video: a #AsVideo instance.
*
* Gets the video codec, if known.
*
* Returns: the #AsVideoCodec
* Returns: the #AsVideoCodecKind
*
**/
AsVideoCodec
as_video_get_codec (AsVideo *video)
AsVideoCodecKind
as_video_get_codec_kind (AsVideo *video)
{
AsVideoPrivate *priv = GET_PRIVATE (video);
return priv->codec;
}
/**
* as_video_set_container:
* as_video_set_container_kind:
* @video: a #AsVideo instance.
* @container: the #AsVideoContainer, e.g. %AS_VIDEO_CONTAINER_MKV.
* @kind: the #AsVideoContainerKind, e.g. %AS_VIDEO_CONTAINER_KIND_MKV.
*
* Sets the video container.
*
**/
void
as_video_set_container (AsVideo *video, AsVideoContainer container)
as_video_set_container_kind (AsVideo *video, AsVideoContainerKind kind)
{
AsVideoPrivate *priv = GET_PRIVATE (video);
priv->container = container;
priv->container = kind;
}
/**
* as_video_get_container:
* as_video_get_container_kind:
* @video: a #AsVideo instance.
*
* Gets the video container format, if known.
*
* Returns: the #AsVideoContainer
* Returns: the #AsVideoContainerKind
*
**/
AsVideoContainer
as_video_get_container (AsVideo *video)
AsVideoContainerKind
as_video_get_container_kind (AsVideo *video)
{
AsVideoPrivate *priv = GET_PRIVATE (video);
return priv->container;
......@@ -378,10 +378,10 @@ as_video_load_from_xml (AsVideo *video, AsContext *ctx, xmlNode *node, GError **
}
codec_kind = (gchar*) xmlGetProp (node, (xmlChar*) "codec");
priv->codec = as_video_codec_from_string (codec_kind);
priv->codec = as_video_codec_kind_from_string (codec_kind);
container_kind = (gchar*) xmlGetProp (node, (xmlChar*) "container");
priv->container = as_video_container_from_string (container_kind);
priv->container = as_video_container_kind_from_string (container_kind);
if (!as_context_has_media_baseurl (ctx)) {
/* no baseurl, we can just set the value as URL */
......@@ -413,10 +413,10 @@ as_video_to_xml_node (AsVideo *video, AsContext *ctx, xmlNode *root)
(xmlChar*) "video",
(xmlChar*) priv->url);
if (priv->codec != AS_VIDEO_CODEC_UNKNOWN)
xmlNewProp (n_video, (xmlChar*) "codec", (xmlChar*) as_video_codec_to_string (priv->codec));
if (priv->container != AS_VIDEO_CONTAINER_UNKNOWN)
xmlNewProp (n_video, (xmlChar*) "container", (xmlChar*) as_video_container_to_string (priv->container));
if (priv->codec != AS_VIDEO_CODEC_KIND_UNKNOWN)
xmlNewProp (n_video, (xmlChar*) "codec", (xmlChar*) as_video_codec_kind_to_string (priv->codec));
if (priv->container != AS_VIDEO_CONTAINER_KIND_UNKNOWN)
xmlNewProp (n_video, (xmlChar*) "container", (xmlChar*) as_video_container_kind_to_string (priv->container));
if ((priv->width > 0) && (priv->height > 0)) {
gchar *size;
......@@ -467,10 +467,10 @@ as_video_load_from_yaml (AsVideo *video, AsContext *ctx, GNode *node, GError **e
priv->height = g_ascii_strtoll (value, NULL, 10);
} else if (g_strcmp0 (key, "codec") == 0) {
priv->codec = as_video_codec_from_string (value);
priv->codec = as_video_codec_kind_from_string (value);
} else if (g_strcmp0 (key, "container") == 0) {
priv->container = as_video_container_from_string (value);
priv->container = as_video_container_kind_from_string (value);
} else if (g_strcmp0 (key, "url") == 0) {
if (as_context_has_media_baseurl (ctx)) {
......@@ -516,8 +516,8 @@ as_video_emit_yaml (AsVideo *video, AsContext *ctx, yaml_emitter_t *emitter)
}
g_strstrip (url);
as_yaml_emit_entry (emitter, "codec", as_video_codec_to_string (priv->codec));
as_yaml_emit_entry (emitter, "container", as_video_container_to_string (priv->container));
as_yaml_emit_entry (emitter, "codec", as_video_codec_kind_to_string (priv->codec));
as_yaml_emit_entry (emitter, "container", as_video_container_kind_to_string (priv->container));
as_yaml_emit_entry (emitter, "url", url);
if ((priv->width > 0) && (priv->height > 0)) {
......
......@@ -45,52 +45,52 @@ struct _AsVideoClass
};
/**
* AsVideoCodec:
* @AS_VIDEO_CODEC_UNKNOWN: Unknown video codec
* @AS_VIDEO_CODEC_VP9: The VP9 video codec
* @AS_VIDEO_CODEC_AV1: The AV1 video codec
* AsVideoCodecKind:
* @AS_VIDEO_CODEC_KIND_UNKNOWN: Unknown video codec
* @AS_VIDEO_CODEC_KIND_VP9: The VP9 video codec
* @AS_VIDEO_CODEC_KIND_AV1: The AV1 video codec
*
* Supported video codecs.
**/
typedef enum {
AS_VIDEO_CODEC_UNKNOWN,
AS_VIDEO_CODEC_VP9,
AS_VIDEO_CODEC_AV1,
AS_VIDEO_CODEC_KIND_UNKNOWN,
AS_VIDEO_CODEC_KIND_VP9,
AS_VIDEO_CODEC_KIND_AV1,
/*< private >*/
AS_VIDEO_CODEC_LAST
} AsVideoCodec;
AS_VIDEO_CODEC_KIND_LAST
} AsVideoCodecKind;
/**
* AsVideoContainer:
* @AS_VIDEO_CONTAINER_UNKNOWN: Unknown video container
* @AS_VIDEO_CONTAINER_MKV: The Matroska video (MKV) container
* @AS_VIDEO_CONTAINER_WEBM: The WebM video container
* AsVideoContainerKind:
* @AS_VIDEO_CONTAINER_KIND_UNKNOWN: Unknown video container
* @AS_VIDEO_CONTAINER_KIND_MKV: The Matroska video (MKV) container
* @AS_VIDEO_CONTAINER_KIND_WEBM: The WebM video container
*
* Supported video codecs.
**/
typedef enum {
AS_VIDEO_CONTAINER_UNKNOWN,
AS_VIDEO_CONTAINER_MKV,
AS_VIDEO_CONTAINER_WEBM,
AS_VIDEO_CONTAINER_KIND_UNKNOWN,
AS_VIDEO_CONTAINER_KIND_MKV,
AS_VIDEO_CONTAINER_KIND_WEBM,
/*< private >*/
AS_VIDEO_CONTAINER_LAST
} AsVideoContainer;
AS_VIDEO_CONTAINER_KIND_LAST
} AsVideoContainerKind;
AsVideoCodec as_video_codec_from_string (const gchar *codec);
const gchar *as_video_codec_to_string (AsVideoCodec codec);
AsVideoCodecKind as_video_codec_kind_from_string (const gchar *str);
const gchar *as_video_codec_kind_to_string (AsVideoCodecKind kind);
AsVideoContainer as_video_container_from_string (const gchar *container);
const gchar *as_video_container_to_string (AsVideoContainer container);
AsVideoContainerKind as_video_container_kind_from_string (const gchar *str);
const gchar *as_video_container_kind_to_string (AsVideoContainerKind kind);
AsVideo *as_video_new (void);
AsVideoCodec as_video_get_codec (AsVideo *video);
void as_video_set_codec (AsVideo *video,
AsVideoCodec codec);
AsVideoCodecKind as_video_get_codec_kind (AsVideo *video);
void as_video_set_codec_kind (AsVideo *video,
AsVideoCodecKind kind);
AsVideoContainer as_video_get_container (AsVideo *video);
void as_video_set_container (AsVideo *video,
AsVideoContainer container);
AsVideoContainerKind as_video_get_container_kind (AsVideo *video);
void as_video_set_container_kind (AsVideo *video,
AsVideoContainerKind kind);
const gchar *as_video_get_url (AsVideo *video);
void as_video_set_url (AsVideo *video,
......
......@@ -1087,15 +1087,15 @@ test_xml_read_screenshots (void)
g_assert_cmpint (videos->len, ==, 2);
vid = AS_VIDEO (g_ptr_array_index (videos, 0));
g_assert_cmpint (as_video_get_codec (vid), ==, AS_VIDEO_CODEC_AV1);
g_assert_cmpint (as_video_get_container (vid), ==, AS_VIDEO_CONTAINER_MKV);
g_assert_cmpint (as_video_get_codec_kind (vid), ==, AS_VIDEO_CODEC_KIND_AV1);
g_assert_cmpint (as_video_get_container_kind (vid), ==, AS_VIDEO_CONTAINER_KIND_MKV);
g_assert_cmpstr (as_video_get_url (vid), ==, "https://example.org/screencast.mkv");
g_assert_cmpint (as_video_get_width (vid), ==, 1916);
g_assert_cmpint (as_video_get_height (vid), ==, 1056);
vid = AS_VIDEO (g_ptr_array_index (videos, 1));
g_assert_cmpint (as_video_get_codec (vid), ==, AS_VIDEO_CODEC_AV1);
g_assert_cmpint (as_video_get_container (vid), ==, AS_VIDEO_CONTAINER_MKV);
g_assert_cmpint (as_video_get_codec_kind (vid), ==, AS_VIDEO_CODEC_KIND_AV1);
g_assert_cmpint (as_video_get_container_kind (vid), ==, AS_VIDEO_CONTAINER_KIND_MKV);
g_assert_cmpstr (as_video_get_url (vid), ==, "https://example.org/screencast_de.mkv");
g_assert_cmpint (as_video_get_width (vid), ==, 1916);
g_assert_cmpint (as_video_get_height (vid), ==, 1056);
......@@ -1183,8 +1183,8 @@ test_xml_write_screenshots (void)
scr3 = as_screenshot_new ();
vid = as_video_new ();
as_video_set_codec (vid, AS_VIDEO_CODEC_AV1);
as_video_set_container (vid, AS_VIDEO_CONTAINER_MKV);
as_video_set_codec_kind (vid, AS_VIDEO_CODEC_KIND_AV1);
as_video_set_container_kind (vid, AS_VIDEO_CONTAINER_KIND_MKV);
as_video_set_width (vid, 1916);
as_video_set_height (vid, 1056);
as_video_set_url (vid, "https://example.org/screencast.mkv");
......@@ -1192,8 +1192,8 @@ test_xml_write_screenshots (void)
g_object_unref (vid);
vid = as_video_new ();
as_video_set_codec (vid, AS_VIDEO_CODEC_AV1);
as_video_set_container (vid, AS_VIDEO_CONTAINER_MKV);
as_video_set_codec_kind (vid, AS_VIDEO_CODEC_KIND_AV1);
as_video_set_container_kind (vid, AS_VIDEO_CONTAINER_KIND_MKV);
as_video_set_locale (vid, "de_DE");
as_video_set_width (vid, 1916);
as_video_set_height (vid, 1056);
......
......@@ -1069,8 +1069,8 @@ test_yaml_write_screenshots (void)
scr2 = as_screenshot_new ();
as_screenshot_set_caption (scr2, "A screencast of this app", "C");
vid = as_video_new ();
as_video_set_codec (vid, AS_VIDEO_CODEC_AV1);
as_video_set_container (vid, AS_VIDEO_CONTAINER_MKV);
as_video_set_codec_kind (vid, AS_VIDEO_CODEC_KIND_AV1);
as_video_set_container_kind (vid, AS_VIDEO_CONTAINER_KIND_MKV);
as_video_set_width (vid, 1916);
as_video_set_height (vid, 1056);
as_video_set_url (vid, "https://example.org/screencast.mkv");
......@@ -1078,8 +1078,8 @@ test_yaml_write_screenshots (void)
g_object_unref (vid);
vid = as_video_new ();
as_video_set_codec (vid, AS_VIDEO_CODEC_AV1);
as_video_set_container (vid, AS_VIDEO_CONTAINER_MKV);
as_video_set_codec_kind (vid, AS_VIDEO_CODEC_KIND_AV1);
as_video_set_container_kind (vid, AS_VIDEO_CONTAINER_KIND_MKV);
as_video_set_locale (vid, "de_DE");
as_video_set_width (vid, 1916);
as_video_set_height (vid, 1056);
......@@ -1164,15 +1164,15 @@ test_yaml_read_screenshots (void)
g_assert_cmpint (videos->len, ==, 2);
vid = AS_VIDEO (g_ptr_array_index (videos, 0));
g_assert_cmpint (as_video_get_codec (vid), ==, AS_VIDEO_CODEC_AV1);
g_assert_cmpint (as_video_get_container (vid), ==, AS_VIDEO_CONTAINER_MKV);
g_assert_cmpint (as_video_get_codec_kind (vid), ==, AS_VIDEO_CODEC_KIND_AV1);
g_assert_cmpint (as_video_get_container_kind (vid), ==, AS_VIDEO_CONTAINER_KIND_MKV);
g_assert_cmpstr (as_video_get_url (vid), ==, "https://example.org/screencast.mkv");
g_assert_cmpint (as_video_get_width (vid), ==, 1916);
g_assert_cmpint (as_video_get_height (vid), ==, 1056);
vid = AS_VIDEO (g_ptr_array_index (videos, 1));
g_assert_cmpint (as_video_get_codec (vid), ==, AS_VIDEO_CODEC_AV1);
g_assert_cmpint (as_video_get_container (vid), ==, AS_VIDEO_CONTAINER_MKV);
g_assert_cmpint (as_video_get_codec_kind (vid), ==, AS_VIDEO_CODEC_KIND_AV1);
g_assert_cmpint (as_video_get_container_kind (vid), ==, AS_VIDEO_CONTAINER_KIND_MKV);
g_assert_cmpstr (as_video_get_url (vid), ==, "https://example.org/screencast_de.mkv");
g_assert_cmpint (as_video_get_width (vid), ==, 1916);
g_assert_cmpint (as_video_get_height (vid), ==, 1056);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment