Frame Buffers

차례

Synopsis
Description
Details

Frame Buffers - support for multimedia frame buffers

Synopsis

#define EDNET_FRAME_HEADER_LEN

enum    EDNetCodecID;
typedef EDNetCodec;
struct  EDNetFrame;
struct  EDNetFrameHeader;
enum    EDNetFrameFlag;
enum    EDNetFrameFormat;

EDNetCodec *ednet_codec_new                      (EDNetCodecID id,
                                                  int          is_encoder,
                                                  int          width,
                                                  int          height,
                                                  int          fps,
                                                  int          bitrate,
                                                  int          gop_size);
EDNetCodec *ednet_codec_ref                      (EDNetCodec  *codec);
void        ednet_codec_unref                    (EDNetCodec  *codec);
int         ednet_codec_decode                   (EDNetCodec  *codec,
                                                  char        *dest,
                                                  int         *dest_len,
                                                  const char  *src,
                                                  int          src_len);
int         ednet_codec_encode                   (EDNetCodec  *codec,
                                                  char        *dest,
                                                  int         *dest_len,
                                                  const char  *src,
                                                  int          src_len,
                                                  int         *is_keyframe);
int         ednet_codec_get_max_audio_frame_size (void);
void        ednet_codec_set_deinterlace          (int          deinterlace);
EDNetFrame *ednet_frame_new                      (unsigned int len,
                                                  uint32_t     timestamp,
                                                  uint8_t      channel,
                                                  uint8_t      ptype,
                                                  uint16_t     flags);
EDNetFrame *ednet_frame_ref                      (EDNetFrame  *frame);
void        ednet_frame_unref                    (EDNetFrame  *frame);

Description

The EDNetFrame is used to pass video and audio frames received from network servers to applications. It may contains frame data in MPEG-4 / H.264 / ADPCM formats or decoded data in YV12 / RGB32 / PCM formats.

Details

EDNET_FRAME_HEADER_LEN

#define EDNET_FRAME_HEADER_LEN (sizeof ())

EDNetCodecID

typedef enum
{
  EDNET_CODEC_VIDEO = 0x00,
  EDNET_CODEC_MPEG4 = 0x01,
  EDNET_CODEC_MJPEG = 0x02,
  EDNET_CODEC_H264  = 0x04,
  EDNET_CODEC_AUDIO = 0x80,
  EDNET_CODEC_ADPCM = 0x83,
  EDNET_CODEC_G726  = 0x84,
  EDNET_CODEC_PCMU  = 0x86
} EDNetCodecID;

Codec types. (Payload)

EDNET_CODEC_VIDEO :

Start number of video codec

EDNET_CODEC_MPEG4 :

MPEG-4

EDNET_CODEC_MJPEG :

MJPEG

EDNET_CODEC_H264 :

H.264

EDNET_CODEC_AUDIO :

Start number of audio codec

EDNET_CODEC_ADPCM :

16bits/8000Hz ADPCM_IMA_WAV

EDNET_CODEC_G726 :

16bits/8000Hz G.726

EDNET_CODEC_PCMU :

8bits/8000Hz G.711 PCMu Law

EDNetCodec

typedef struct _EDNetCodec EDNetCodec;

Coder and Decoder object.

EDNetFrame

typedef struct
{
  EDNetBuf buf;
  uint32_t timestamp;
  uint8_t  channel;
  uint8_t  ptype;
  uint16_t flags;
  int      fmt;
  int      width;
  int      height;
} EDNetFrame;

A Buffer used for multimedia video / audio frames, which supports basic reference counting mechanism and frame information.

EDNetBuf buf :

a buffer, the base object

uint32_t timestamp :

timestamp

uint8_t channel :

channel number

uint8_t ptype :

payload, see EDNetCodecID

uint16_t flags :

flags, see EDNetFrameFlag

int fmt :

format, see EDNetFrameFormat

int width :

The width of video frame

int height :

The height of video frame

EDNetFrameHeader

typedef struct
{
  uint32_t skey;
  uint32_t timestamp;
  uint32_t size;
  uint32_t offset;
  uint8_t  channel;
  uint8_t  ptype;
  uint16_t flags;
} EDNetFrameHeader;

uint32_t skey :

Session key

uint32_t timestamp :

Timestamp

uint32_t size :

Frame size

uint32_t offset :

Offset

uint8_t channel :

Channel number

uint8_t ptype :

see EDNetCodecID

uint16_t flags :

see EDNetFrameFlag

EDNetFrameFlag

typedef enum
{
  EDNET_FRAME_FLAG_KEY_FRAME = 1 << 0,
  EDNET_FRAME_FLAG_VIDEO     = 1 << 1,
  EDNET_FRAME_FLAG_AUDIO     = 1 << 2
} EDNetFrameFlag;

Frame flags

EDNET_FRAME_FLAG_KEY_FRAME :

it's a key frame.

EDNET_FRAME_FLAG_VIDEO :

it contains video data.

EDNET_FRAME_FLAG_AUDIO :

it contains audio data.

EDNetFrameFormat

typedef enum
{
  EDNET_FRAME_FORMAT_ENCODED = 0,
  EDNET_FRAME_FORMAT_YV12,
  EDNET_FRAME_FORMAT_RGB32,
  EDNET_FRAME_FORMAT_RGB24,
  EDNET_FRAME_FORMAT_RGB16,
  EDNET_FRAME_FORMAT_PCM
} EDNetFrameFormat;

Frame formats

EDNET_FRAME_FORMAT_ENCODED :

encoded, see EDNetCodecID

EDNET_FRAME_FORMAT_YV12 :

YV12

EDNET_FRAME_FORMAT_RGB32 :

RGB32

EDNET_FRAME_FORMAT_RGB24 :

RGB24

EDNET_FRAME_FORMAT_RGB16 :

RGB16

EDNET_FRAME_FORMAT_PCM :

PCM (16 bits, 8000Hz, Mono)

ednet_codec_new ()

EDNetCodec *ednet_codec_new                      (EDNetCodecID id,
                                                  int          is_encoder,
                                                  int          width,
                                                  int          height,
                                                  int          fps,
                                                  int          bitrate,
                                                  int          gop_size);

새로운 코덱 객체를 생성합니다.

id :

codec ID

is_encoder :

TRUE or FALSE

width :

the width of video frames

height :

the height of video frames

fps :

frame rates

bitrate :

bit rates

gop_size :

key frame interval

Returns :

On success a newly created codec object, otherwise NULL.

ednet_codec_ref ()

EDNetCodec *ednet_codec_ref                      (EDNetCodec  *codec);

Increases the reference count on a codec by 1.

ednet_codec_unref ()

void        ednet_codec_unref                    (EDNetCodec  *codec);

Decreases the reference count on a codec by 1.

ednet_codec_decode ()

int         ednet_codec_decode                   (EDNetCodec  *codec,
                                                  char        *dest,
                                                  int         *dest_len,
                                                  const char  *src,
                                                  int          src_len);

코덱을 이용하여 비디오 영상을 복호화(Decoding) 합니다.

codec :

EDNetCodec 객체

dest :

복호화 한 프레임을 넣을 버퍼

dest_len :

복호화 한 프레임을 넣을 버퍼의 크기

src :

복호화 할 데이터

src_len :

복호화 할 데이터 크기

Returns :

정상적으로 복호화 했을 경우 0, 그렇지 않으면 -1

ednet_codec_encode ()

int         ednet_codec_encode                   (EDNetCodec  *codec,
                                                  char        *dest,
                                                  int         *dest_len,
                                                  const char  *src,
                                                  int          src_len,
                                                  int         *is_keyframe);

코덱을 이용하여 부호화(Encoding) 합니다.

codec :

EDNetCodec 객체

dest :

부호화 한 데이터를 넣을 버퍼

dest_len :

부호화 한 데이터를 넣을 버퍼의 크기

src :

부호화 할 데이터

src_len :

부호화 할 데이터 크기

is_keyframe :

a pointer to variable to be stored with it's key frame

Returns :

정상적으로 부호화 했을 경우 0, 그렇지 않으면 -1

ednet_codec_get_max_audio_frame_size ()

int         ednet_codec_get_max_audio_frame_size (void);

오디오 프레임의 최대 크기를 얻어옵니다.

Returns :

AVCODEC_MAX_AUDIO_FRAME_SIZE

ednet_codec_set_deinterlace ()

void        ednet_codec_set_deinterlace          (int          deinterlace);

디인터레이스 필터를 사용할지 여부를 설정합니다.

deinterlace :

디인터레이스 필터를 사용하면 TRUE

ednet_frame_new ()

EDNetFrame *ednet_frame_new                      (unsigned int len,
                                                  uint32_t     timestamp,
                                                  uint8_t      channel,
                                                  uint8_t      ptype,
                                                  uint16_t     flags);

Creates a new frame buffer object whose data space will be allocated with specified size, and filled with specified information.

len :

the length of a frame data

timestamp :

timestamp

channel :

channel number (see EDNET_CHANNEL_MAX, EDNET_CHANNEL_AUDIO)

ptype :

payload (see EDNetCodecID)

flags :

flags (see EDNetFrameFlag)

Returns :

a new EDNetFrame, NULL if an error occurred.

ednet_frame_ref ()

EDNetFrame *ednet_frame_ref                      (EDNetFrame  *frame);

Adds a reference to the frame.

frame :

a EDNetFrame

ednet_frame_unref ()

void        ednet_frame_unref                    (EDNetFrame  *frame);

Removes a reference from the frame, deallocating the buffer if no references remain.

frame :

a EDNetFrame