Skip to content

Commit

Permalink
fix examples with new folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mashingan committed Jan 6, 2020
1 parent ec3e3fc commit c6dcd33
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 55 deletions.
1 change: 0 additions & 1 deletion config.nims

This file was deleted.

6 changes: 1 addition & 5 deletions examples/fplay.nim
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# the tutorial repo is from
# https://github.com/leixiaohua1020/simplest_ffmpeg_player

import
utiltypes,
libavcodec/avcodec,
libavformat/avformat,
libavutil/[frame, samplefmt]
import ffmpeg

import sdl2, sdl2/audio

Expand Down
5 changes: 1 addition & 4 deletions examples/ftut.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# This example is taken from ffmpeg tutorial page
# https://github.com/leandromoreira/ffmpeg-libav-tutorial

import libavcodec/avcodec
import libavformat/avformat
import libavutil/[log, frame]
import utiltypes
import ffmpeg
import os, strformat, strutils, streams
import sugar

Expand Down
41 changes: 23 additions & 18 deletions src/ffmpeg.nim
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
{.passC: "-I../cinclude".}

import ffmpeg/utiltypes

import ffmpeg/libavcodec/[avcodec, ac3_parser, adts_parser, avdct,
avfft, d3d11va, dirac, dv_profile, dxva2,
#jni, mediacodec, qsv, vaapi, vdpau, version,
jni, mediacodec, vaapi, vdpau, version,
videotoolbox, vorbis_parser, xvmc]
avfft, dirac, dv_profile, dxva2,
jni, mediacodec, vorbis_parser]

when defined(windows):
import ffmpeg/libavcodec/d3d11va
else:
import ffmpeg/libavcodec/[vaapi, vdpau, xvmc]

import ffmpeg/libavdevice/avdevice
import ffmpeg/libavdevice/version as dvcversion

#add libavfilter import

import ffmpeg/libavformat/[avformat, avio]
import ffmpeg/libavformat/version as fmtversion

import ffmpeg/libavutil/[log, avutil, common, dict, frame, hwcontext,
opt, pixdesc, pixfmt, rational, samplefmt,
channel_layout, avconfig, buffer, adler32,
aes, aes_ctr, imgutils]
import ffmpeg/libavutil/version as utilversion

#add libpostproc import

import ffmpeg/libswresample/swresample
import ffmpeg/libswresample/version as resampleVersion

import ffmpeg/libswscale/swscale
import ffmpeg/libswscale/version as scaleVersion

export utiltypes

export avcodec, ac3_parser, adts_parser, avdct,
avfft, d3d11va, dirac, dv_profile, dxva2,
jni, mediacodec, qsv, vaapi, vdpau, version,
videotoolbox, vorbis_parser, xvmc
avfft, dirac, dv_profile, dxva2,
jni, mediacodec, vorbis_parser

when defined(windows):
export d3d11va
else:
export vaapi, vdpau, xvmc

export avdevice, dvcversion
export avdevice

export avformat, avio, fmtversion
export avformat, avio

export log, avutil, common, dict, frame, hwcontext,
opt, pixdesc, pixfmt, rational, samplefmt,
channel_layout, avconfig, buffer, utilversion,
adler32, aes, aes_ctr, imgutils
channel_layout, avconfig, buffer, adler32,
aes, aes_ctr, imgutils

export swresample, resampleVersion
export swresample

export swscale, scaleVersion
export swscale
25 changes: 18 additions & 7 deletions src/ffmpeg/libavcodec/vorbis_parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,27 @@
## Allocate and initialize the Vorbis parser using headers in the extradata.
##

proc av_vorbis_parse_init*(extradata: ptr uint8_t; extradata_size: cint): ptr AVVorbisParseContext
const
VORBIS_FLAG_HEADER* = 0x00000001
VORBIS_FLAG_COMMENT* = 0x00000002
VORBIS_FLAG_SETUP* = 0x00000004

type
AVVorbisParseContext* {.importc, header: "<libavcodec/vorbis_parser.h>".} = object

when defined(windows):
{.push importc, dynlib: "avcodec(|-55|-56|-57|-58|-59).dll".}
elif defined(macosx):avcodec
{.push importc, dynlib: "avcodec(|.55|.56|.57|.58|.59).dylib".}
else:avcodec
{.push importc, dynlib: "avcodec.so(|.55|.56|.57|.58|.59)".}

proc av_vorbis_parse_init*(extradata: ptr uint8; extradata_size: cint): ptr AVVorbisParseContext
## *
## Free the parser and everything associated with it.
##

proc av_vorbis_parse_free*(s: ptr ptr AVVorbisParseContext)
const
VORBIS_FLAG_HEADER* = 0x00000001
VORBIS_FLAG_COMMENT* = 0x00000002
VORBIS_FLAG_SETUP* = 0x00000004

## *
## Get the duration for a Vorbis packet.
Expand All @@ -50,7 +61,7 @@ const
## @param flags flags for special frames
##

proc av_vorbis_parse_frame_flags*(s: ptr AVVorbisParseContext; buf: ptr uint8_t;
proc av_vorbis_parse_frame_flags*(s: ptr AVVorbisParseContext; buf: ptr uint8;
buf_size: cint; flags: ptr cint): cint
## *
## Get the duration for a Vorbis packet.
Expand All @@ -60,6 +71,6 @@ proc av_vorbis_parse_frame_flags*(s: ptr AVVorbisParseContext; buf: ptr uint8_t;
## @param buf_size size of the buffer
##

proc av_vorbis_parse_frame*(s: ptr AVVorbisParseContext; buf: ptr uint8_t;
proc av_vorbis_parse_frame*(s: ptr AVVorbisParseContext; buf: ptr uint8;
buf_size: cint): cint
proc av_vorbis_parse_reset*(s: ptr AVVorbisParseContext)
3 changes: 1 addition & 2 deletions src/ffmpeg/libavcodec/xvmc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
## Public libavcodec XvMC header.
##

import
libavutil/attributes, version, avcodec
#import libavutil/attributes, version, avcodec

## *
## @defgroup lavc_codec_hwaccel_xvmc XvMC
Expand Down
13 changes: 10 additions & 3 deletions src/ffmpeg/libavutil/adler32.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
## Public header for Adler-32 hash function implementation.
##

import
attributes
#import attributes

## *
## @defgroup lavu_adler32 Adler-32
Expand All @@ -46,7 +45,15 @@ import
## @return updated checksum
##

proc av_adler32_update*(adler: culong; buf: ptr uint8_t; len: cuint): culong

when defined(windows):
{.push importc, dynlib: "avutil(|-55|-56|-57).dll".}
elif defined(macosx):
{.push importc, dynlib: "avutil(|.55|.56|.57).dylib".}
else:
{.push importc, dynlib: "avutil.so(|.55|.56|.57)".}

proc av_adler32_update*(adler: culong; buf: ptr uint8; len: cuint): culong
## unsigned int len) av_pure;
## *
## @}
Expand Down
18 changes: 12 additions & 6 deletions src/ffmpeg/libavutil/aes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
##

import
attributes, version
#import attributes, version

## *
## @defgroup lavu_aes AES
Expand All @@ -30,7 +29,14 @@ import
var av_aes_size*: cint

type
AVAES* {.bycopy.} = object
AVAES* {.importc, header: "<libavutil/aes.h>".} = object

when defined(windows):
{.push importc, dynlib: "avutil(|-55|-56|-57).dll".}
elif defined(macosx):
{.push importc, dynlib: "avutil(|.55|.56|.57).dylib".}
else:
{.push importc, dynlib: "avutil.so(|.55|.56|.57)".}


## *
Expand All @@ -44,7 +50,7 @@ proc av_aes_alloc*(): ptr AVAES
## @param decrypt 0 for encryption, 1 for decryption
##

proc av_aes_init*(a: ptr AVAES; key: ptr uint8_t; key_bits: cint; decrypt: cint): cint
proc av_aes_init*(a: ptr AVAES; key: ptr uint8; key_bits: cint; decrypt: cint): cint
## *
## Encrypt or decrypt a buffer using a previously initialized context.
## @param count number of 16 byte blocks
Expand All @@ -54,8 +60,8 @@ proc av_aes_init*(a: ptr AVAES; key: ptr uint8_t; key_bits: cint; decrypt: cint)
## @param decrypt 0 for encryption, 1 for decryption
##

proc av_aes_crypt*(a: ptr AVAES; dst: ptr uint8_t; src: ptr uint8_t; count: cint;
iv: ptr uint8_t; decrypt: cint)
proc av_aes_crypt*(a: ptr AVAES; dst: ptr uint8; src: ptr uint8; count: cint;
iv: ptr uint8; decrypt: cint)
## *
## @}
##
21 changes: 13 additions & 8 deletions src/ffmpeg/libavutil/aes_ctr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,22 @@
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
##

import
attributes, version

const
AES_CTR_KEY_SIZE* = (16)
AES_CTR_IV_SIZE* = (8)

type
AVAESCTR* {.bycopy.} = object
AVAESCTR* {.importc, header: "<libavutil/aes_ctr.h>".} = object


when defined(windows):
{.push importc, dynlib: "avutil(|-55|-56|-57).dll".}
elif defined(macosx):
{.push importc, dynlib: "avutil(|.55|.56|.57).dylib".}
else:
{.push importc, dynlib: "avutil.so(|.55|.56|.57)".}

## *
## Allocate an AVAESCTR context.
##
Expand All @@ -40,7 +45,7 @@ proc av_aes_ctr_alloc*(): ptr AVAESCTR
## @param key encryption key, must have a length of AES_CTR_KEY_SIZE
##

proc av_aes_ctr_init*(a: ptr AVAESCTR; key: ptr uint8_t): cint
proc av_aes_ctr_init*(a: ptr AVAESCTR; key: ptr uint8): cint
## *
## Release an AVAESCTR context.
##
Expand All @@ -53,12 +58,12 @@ proc av_aes_ctr_free*(a: ptr AVAESCTR)
## @param size the size of src and dst
##

proc av_aes_ctr_crypt*(a: ptr AVAESCTR; dst: ptr uint8_t; src: ptr uint8_t; size: cint)
proc av_aes_ctr_crypt*(a: ptr AVAESCTR; dst: ptr uint8; src: ptr uint8; size: cint)
## *
## Get the current iv
##

proc av_aes_ctr_get_iv*(a: ptr AVAESCTR): ptr uint8_t
proc av_aes_ctr_get_iv*(a: ptr AVAESCTR): ptr uint8
## *
## Generate a random iv
##
Expand All @@ -68,12 +73,12 @@ proc av_aes_ctr_set_random_iv*(a: ptr AVAESCTR)
## Forcefully change the 8-byte iv
##

proc av_aes_ctr_set_iv*(a: ptr AVAESCTR; iv: ptr uint8_t)
proc av_aes_ctr_set_iv*(a: ptr AVAESCTR; iv: ptr uint8)
## *
## Forcefully change the "full" 16-byte iv, including the counter
##

proc av_aes_ctr_set_full_iv*(a: ptr AVAESCTR; iv: ptr uint8_t)
proc av_aes_ctr_set_full_iv*(a: ptr AVAESCTR; iv: ptr uint8)
## *
## Increment the top 64 bit of the iv (performed after each frame)
##
Expand Down
2 changes: 1 addition & 1 deletion src/ffmpeg/libavutil/opt.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
##

import
rational, avutil, dict, ../utiltypes
rational, avutil, dict, ../utiltypes, pixfmt

when defined(windows):
{.push importc, dynlib: "avformat(|-55|-56|-57|-58).dll".}
Expand Down

0 comments on commit c6dcd33

Please sign in to comment.