mustafa.yavuz
mustafa.yavuz

Reputation: 1294

Enum with functions in C

While I examine the source code of ffmpeg, I see this line:

enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method
(const AVFormatContext* ctx);

What is the functionality of enum here?

Upvotes: 1

Views: 225

Answers (6)

Yu Hao
Yu Hao

Reputation: 122493

enum AVDurationEstimationMethod together is a type which the function av_fmt_ctx_get_duration_estimation_method returns

The keyword enum, like struct and union, is necessary to represent the type. To omit it, use typedef:

typedef enum AVDurationEstimationMethod sometype;

Then you can use it like:

sometype av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx);

Upvotes: 5

Kolyunya
Kolyunya

Reputation: 6240

The code you posted is a declaration of a function which returns an instance of enum AVDurationEstimationMethod which is an enumeration type.

Upvotes: 3

Jeyaram
Jeyaram

Reputation: 9504

av_fmt_ctx_get_duration_estimation_method is a function which returns an object of enum type AVDurationEstimationMethod .

Upvotes: 8

Sean
Sean

Reputation: 62532

In C enums effectivly live in their own 'namespace' (this is also the case for structs). To make it clear that you're specify an enum type you must prefix it with the enum keyword.

Upvotes: 3

No Idea For Name
No Idea For Name

Reputation: 11597

here you can find about the method, and here about the enum return type

Upvotes: 0

Chinna
Chinna

Reputation: 4002

Here the function av_fmt_ctx_get_duration_estimation_method(); is taking const AVFormatContext* ctx as argument and returning enum AVDurationEstimationMethod

Upvotes: 1

Related Questions