[FFmpeg-devel] [PATCH 1/2] lavf: add control message API

Lukasz Marek lukasz.m.luki at gmail.com
Sat Jan 25 16:02:32 CET 2014


On 25.01.2014 03:08, Michael Niedermayer wrote:
> On Thu, Jan 23, 2014 at 11:39:47PM +0100, Lukasz Marek wrote:
>> On 21.01.2014 13:06, Stefano Sabatini wrote:
>>> On date Sunday 2014-01-19 17:33:26 +0100, Lukasz M encoded:
>>>> On 19 January 2014 12:21, Nicolas George <george at nsup.org> wrote:
>>> [...]
>>>>  From 9bd80a1cb97948c3ce29bc413fe617116ab49670 Mon Sep 17 00:00:00 2001
>>>> From: Lukasz Marek <lukasz.m.luki at gmail.com>
>>>> Date: Sun, 19 Jan 2014 16:11:09 +0100
>>>> Subject: [PATCH 1/3] lavf: add avformat_dev_control_message API
>>>>
>>>> New API allows to send messages from application to devices.
>>>
>>> Can you shortly describe an use case?
>>>
>>> Also, is this specific of devices? In this case we should probably
>>> move it to libavdevice.
>>>
>>
>> Implementation and typedefs moved to libavdevice.
>> Patches attached.
>
>>   libavdevice/avdevice.c |    8 ++++++++
>>   libavdevice/avdevice.h |   30 ++++++++++++++++++++++++++++++
>>   libavdevice/version.h  |    4 ++--
>>   libavformat/avformat.h |    5 +++++
>>   libavformat/version.h  |    4 ++--
>>   5 files changed, 47 insertions(+), 4 deletions(-)
>> 5a5646fcd67f777bfa5a7b8b62a12ad52c02fa40  0001-lavf-add-avformat_dev_control_message-API.patch
>>  From 0a541e4600ea2572c93d9bd9e0dd9fff5ba077a2 Mon Sep 17 00:00:00 2001
>> From: Lukasz Marek <lukasz.m.luki at gmail.com>
>> Date: Sun, 19 Jan 2014 16:11:09 +0100
>> Subject: [PATCH 1/3] lavf: add avformat_dev_control_message API
>>
>> New API allows to send messages from application to devices.
>>
>> Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
>> ---
>>   libavdevice/avdevice.c |  8 ++++++++
>>   libavdevice/avdevice.h | 30 ++++++++++++++++++++++++++++++
>>   libavdevice/version.h  |  4 ++--
>>   libavformat/avformat.h |  5 +++++
>>   libavformat/version.h  |  4 ++--
>>   5 files changed, 47 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
>> index b9b18f2..5529be3 100644
>> --- a/libavdevice/avdevice.c
>> +++ b/libavdevice/avdevice.c
>> @@ -36,3 +36,11 @@ const char * avdevice_license(void)
>>   #define LICENSE_PREFIX "libavdevice license: "
>>       return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
>>   }
>> +
>> +int avdevice_dev_control_message(struct AVFormatContext *s, enum AVDeviceMessageType type,
>> +                                 void *data, size_t data_size)
>> +{
>> +    if (!s->oformat || !s->oformat->control_message)
>> +        return AVERROR(ENOSYS);
>> +    return s->oformat->control_message(s, type, data, data_size);
>> +}
>> diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
>> index 93a044f..9f801b5 100644
>> --- a/libavdevice/avdevice.h
>> +++ b/libavdevice/avdevice.h
>> @@ -66,4 +66,34 @@ const char *avdevice_license(void);
>>    */
>>   void avdevice_register_all(void);
>>
>> +/**
>> + * Structure with data for AV_DEVICE_WINDOW_GEOMETRY message.
>> + */
>> +typedef struct AVDeviceWindowGeometry {
>> +    int width;  /**< window width */
>> +    int height; /**< window height */
>> +} AVDeviceWindowGeometry;
>> +
>> +/**
>> + * Message types used by avformat_dev_control_message().
>> + */
>
>> +enum AVDeviceMessageType {
>> +    AV_DEVICE_NONE = MKBETAG('N','O','N','E'),
>> +    AV_DEVICE_WINDOW_GEOMETRY = MKBETAG('G','E','O','M'),              /**< Window geometry change message */
>> +    AV_DEVICE_WINDOW_REPAINT = MKBETAG('R','E','P','A')                /**< Repaint request */
>> +};
>
> each of these should describe what the data has to be

Added

>
>
> [...]
>> diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h
>> index 9f801b5..2e9b9bb 100644
>> --- a/libavdevice/avdevice.h
>> +++ b/libavdevice/avdevice.h
>> @@ -84,6 +84,17 @@ enum AVDeviceMessageType {
>>   };
>>
>>   /**
>> + * Message types used by avformat_app_control_message().
>> + */
>> +enum AVApplicationMessageType {
>> +    AV_CTL_NONE = MKBETAG('N','O','N','E'),
>> +    AV_CTL_MESSAGE_PREPARE_WINDOW_BUFFER = MKBETAG('W','P','R','E'),   /**< Application is asked to prepare buffer for rendering */
>> +    AV_CTL_MESSAGE_DISPLAY_WINDOW_BUFFER = MKBETAG('W','D','I','S'),   /**< Application is asked to present buffer to the user */
>> +    AV_CTL_MESSAGE_CREATE_WINDOW_BUFFER = MKBETAG('W','C','R','E'),    /**< Application is asked to create buffer */
>> +    AV_CTL_MESSAGE_DESTROY_WINDOW_BUFFER = MKBETAG('W','D','E','S')    /**< Application is asked to release buffer */
>> +};
>
> each of these should describe what the data has to be
> and what the message means exactly

Added

> also iam missing human interface stuff/ mouse/keyboard stuff,
> window move/resize/iconify/... events, ...
> theres no need to implement that now but some placeholder or todo
> probably would make sense at least

I propose I prepare separate commit for it. I don't want to delay this 
patch set.

> also maybe rename it to enum AVDevToAppMessageType, as its a
> bit ambiguous otherwise which is which (at least to me)

Agree, I changed function names and enums.

> [...]
>> diff --git a/libavdevice/version.h b/libavdevice/version.h
>> index bfd4a70..a621775 100644
>> --- a/libavdevice/version.h
>> +++ b/libavdevice/version.h
>> @@ -28,7 +28,7 @@
>>   #include "libavutil/version.h"
>>
>>   #define LIBAVDEVICE_VERSION_MAJOR  55
>> -#define LIBAVDEVICE_VERSION_MINOR   6
>> +#define LIBAVDEVICE_VERSION_MINOR   7
>>   #define LIBAVDEVICE_VERSION_MICRO 100
>>
>>   #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>> index 1216fe0..c28fe8c 100644
>> --- a/libavformat/avformat.h
>> +++ b/libavformat/avformat.h
>> @@ -953,6 +953,13 @@ typedef struct AVChapter {
>>
>>
>>   /**
>> + * Callback used by devices to communicate with application.
>> + */
>> +typedef int (*av_format_control_message)(struct AVFormatContext *s, int type,
>> +                                         void *data, size_t data_size);
>> +
>> +
>> +/**
>>    * The duration of a video can be estimated through various ways, and this enum can be used
>>    * to know how the duration was estimated.
>>    */
>
>> @@ -1353,6 +1360,17 @@ typedef struct AVFormatContext {
>>        * Demuxing: Set by user via av_format_set_subtitle_codec (NO direct access).
>>        */
>>       AVCodec *subtitle_codec;
>> +
>> +    /**
>> +     * User data.
>> +     */
>
> that is not enough, with this i have about 0 clue what to do with this
> field

Updated.

New patches attached.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavd-add-avdevice_app_to_dev_control_message-API.patch
Type: text/x-patch
Size: 4876 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140125/4d5266c4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lavd-add-avdevice_dev_to_app_control_message-API.patch
Type: text/x-patch
Size: 7386 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140125/4d5266c4/attachment-0001.bin>


More information about the ffmpeg-devel mailing list