*: use latest ffmpeg-sys using bindgen

* Update bindings to newest ffmpeg version for new ffmpeg-sys, which is mostly generated by bindgen
* Bring back removed feature flags
* Fix whitespace formating
* Remove prepended enum names to enum variants
* Remove unneeded allows
This commit is contained in:
Tadas Barzdžius
2017-07-08 17:00:27 +02:00
committed by meh
parent 8cf47c7ec6
commit 5ac0527bdc
41 changed files with 208 additions and 99 deletions
+1
View File
@@ -1,4 +1,5 @@
use ffi::*;
use ffi::AVAudioServiceType::*;
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum AudioService {
+1 -1
View File
@@ -54,7 +54,7 @@ impl Codec {
pub fn medium(&self) -> media::Type {
unsafe {
media::Type::from((*self.as_ptr()).kind)
media::Type::from((*self.as_ptr()).type_)
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ impl Subtitle {
unsafe {
let mut got: c_int = 0;
match avcodec_decode_subtitle2(self.as_mut_ptr(), out.as_mut_ptr(), &mut got, packet.as_ptr()) {
match avcodec_decode_subtitle2(self.as_mut_ptr(), out.as_mut_ptr(), &mut got, packet.as_ptr() as *mut _) {
e if e < 0 => Err(Error::from(e)),
_ => Ok(got != 0)
}
+1
View File
@@ -1,4 +1,5 @@
use ffi::*;
use ffi::AVDiscard::*;
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum Discard {
+1
View File
@@ -1,4 +1,5 @@
use ffi::*;
use ffi::AVFieldOrder::*;
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum FieldOrder {
+41 -2
View File
@@ -2,6 +2,7 @@ use std::ffi::CStr;
use std::str::from_utf8_unchecked;
use ffi::*;
use ffi::AVCodecID::*;
use ::util::media;
#[allow(non_camel_case_types)]
@@ -458,6 +459,19 @@ pub enum Id {
MPEG4SYSTEMS,
FFMETADATA,
WRAPPED_AVFRAME,
PSD,
PIXLET,
SPEEDHQ,
CLEARVIDEO,
FMVC,
SCPR,
XPM,
AV1,
PCM_F16LE,
PCM_F24LE,
ATRAC3AL,
ATRAC3PAL,
}
impl Id {
@@ -925,6 +939,18 @@ impl From<AVCodecID> for Id {
AV_CODEC_ID_MPEG4SYSTEMS => Id::MPEG4SYSTEMS,
AV_CODEC_ID_FFMETADATA => Id::FFMETADATA,
AV_CODEC_ID_WRAPPED_AVFRAME => Id::WRAPPED_AVFRAME,
AV_CODEC_ID_PSD => Id::PSD,
AV_CODEC_ID_PIXLET => Id::PIXLET,
AV_CODEC_ID_SPEEDHQ => Id::SPEEDHQ,
AV_CODEC_ID_CLEARVIDEO => Id::CLEARVIDEO,
AV_CODEC_ID_FMVC => Id::FMVC,
AV_CODEC_ID_SCPR => Id::SCPR,
AV_CODEC_ID_XPM => Id::XPM,
AV_CODEC_ID_AV1 => Id::AV1,
AV_CODEC_ID_PCM_F16LE => Id::PCM_F16LE,
AV_CODEC_ID_PCM_F24LE => Id::PCM_F24LE,
AV_CODEC_ID_ATRAC3AL => Id::ATRAC3AL,
AV_CODEC_ID_ATRAC3PAL => Id::ATRAC3PAL,
}
}
}
@@ -1073,7 +1099,7 @@ impl Into<AVCodecID> for Id {
Id::ANM => AV_CODEC_ID_ANM,
Id::BINKVIDEO => AV_CODEC_ID_BINKVIDEO,
Id::IFF_ILBM => AV_CODEC_ID_IFF_ILBM,
Id::IFF_BYTERUN1 => AV_CODEC_ID_IFF_BYTERUN1,
Id::IFF_BYTERUN1 => AV_CODEC_ID_IFF_ILBM,
Id::KGV1 => AV_CODEC_ID_KGV1,
Id::YOP => AV_CODEC_ID_YOP,
Id::VP8 => AV_CODEC_ID_VP8,
@@ -1111,7 +1137,7 @@ impl Into<AVCodecID> for Id {
Id::WEBP => AV_CODEC_ID_WEBP,
Id::HNM4_VIDEO => AV_CODEC_ID_HNM4_VIDEO,
Id::HEVC => AV_CODEC_ID_HEVC,
Id::H265 => AV_CODEC_ID_H265,
Id::H265 => AV_CODEC_ID_HEVC,
Id::FIC => AV_CODEC_ID_FIC,
Id::ALIAS_PIX => AV_CODEC_ID_ALIAS_PIX,
Id::BRENDER_PIX => AV_CODEC_ID_BRENDER_PIX,
@@ -1383,6 +1409,19 @@ impl Into<AVCodecID> for Id {
Id::MPEG4SYSTEMS => AV_CODEC_ID_MPEG4SYSTEMS,
Id::FFMETADATA => AV_CODEC_ID_FFMETADATA,
Id::WRAPPED_AVFRAME => AV_CODEC_ID_WRAPPED_AVFRAME,
Id::PSD => AV_CODEC_ID_PSD,
Id::PIXLET => AV_CODEC_ID_PIXLET,
Id::SPEEDHQ => AV_CODEC_ID_SPEEDHQ,
Id::FMVC => AV_CODEC_ID_FMVC,
Id::CLEARVIDEO => AV_CODEC_ID_CLEARVIDEO,
Id::SCPR => AV_CODEC_ID_SCPR,
Id::XPM => AV_CODEC_ID_XPM,
Id::AV1 => AV_CODEC_ID_AV1,
Id::PCM_F16LE => AV_CODEC_ID_PCM_F16LE,
Id::PCM_F24LE => AV_CODEC_ID_PCM_F24LE,
Id::ATRAC3AL => AV_CODEC_ID_ATRAC3AL,
Id::ATRAC3PAL => AV_CODEC_ID_ATRAC3PAL,
}
}
}
+2 -2
View File
@@ -208,7 +208,7 @@ impl Packet {
return Err(Error::InvalidData);
}
match av_write_frame(format.as_mut_ptr(), self.as_ptr()) {
match av_write_frame(format.as_mut_ptr(), self.as_ptr() as *mut _) {
1 => Ok(true),
0 => Ok(false),
e => Err(Error::from(e))
@@ -223,7 +223,7 @@ impl Packet {
return Err(Error::InvalidData);
}
match av_interleaved_write_frame(format.as_mut_ptr(), self.as_ptr()) {
match av_interleaved_write_frame(format.as_mut_ptr(), self.as_ptr() as *mut _) {
1 => Ok(true),
0 => Ok(false),
e => Err(Error::from(e))
+11 -4
View File
@@ -2,6 +2,7 @@ use std::marker::PhantomData;
use std::slice;
use ffi::*;
use ffi::AVPacketSideDataType::*;
use super::Packet;
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
@@ -26,7 +27,9 @@ pub enum Type {
WebVTTSettings,
MetadataUpdate,
MPEGTSStreamID,
MasteringDisplayMetadata
MasteringDisplayMetadata,
DataSpherical,
DataNb,
}
impl From<AVPacketSideDataType> for Type {
@@ -52,7 +55,9 @@ impl From<AVPacketSideDataType> for Type {
AV_PKT_DATA_WEBVTT_SETTINGS => Type::WebVTTSettings,
AV_PKT_DATA_METADATA_UPDATE => Type::MetadataUpdate,
AV_PKT_DATA_MPEGTS_STREAM_ID => Type::MPEGTSStreamID,
AV_PKT_DATA_MASTERING_DISPLAY_METADATA => Type::MasteringDisplayMetadata
AV_PKT_DATA_MASTERING_DISPLAY_METADATA => Type::MasteringDisplayMetadata,
AV_PKT_DATA_SPHERICAL => Type::DataSpherical,
AV_PKT_DATA_NB => Type::DataNb,
}
}
}
@@ -80,7 +85,9 @@ impl Into<AVPacketSideDataType> for Type {
Type::WebVTTSettings => AV_PKT_DATA_WEBVTT_SETTINGS,
Type::MetadataUpdate => AV_PKT_DATA_METADATA_UPDATE,
Type::MPEGTSStreamID => AV_PKT_DATA_MPEGTS_STREAM_ID,
Type::MasteringDisplayMetadata => AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Type::MasteringDisplayMetadata => AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
Type::DataSpherical => AV_PKT_DATA_SPHERICAL,
Type::DataNb => AV_PKT_DATA_NB,
}
}
}
@@ -104,7 +111,7 @@ impl<'a> SideData<'a> {
impl<'a> SideData<'a> {
pub fn kind(&self) -> Type {
unsafe {
Type::from((*self.as_ptr()).kind)
Type::from((*self.as_ptr()).type_)
}
}
+2 -1
View File
@@ -12,6 +12,7 @@ use std::mem;
use libc::{c_uint, uint32_t, size_t};
use ffi::*;
use ffi::AVSubtitleType::*;
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum Type {
@@ -105,7 +106,7 @@ impl Subtitle {
as *mut _;
let mut rect = av_mallocz(mem::size_of::<AVSubtitleRect>() as size_t) as *mut AVSubtitleRect;
(*rect).kind = kind.into();
(*rect).type_ = kind.into();
*self.0.rects.offset((self.0.num_rects - 1) as isize) = rect;
+1 -1
View File
@@ -15,7 +15,7 @@ pub enum Rect<'a> {
impl<'a> Rect<'a> {
pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self {
match Type::from((*ptr).kind) {
match Type::from((*ptr).type_) {
Type::None => Rect::None(ptr),
Type::Bitmap => Rect::Bitmap(Bitmap::wrap(ptr)),
Type::Text => Rect::Text(Text::wrap(ptr)),
+2 -2
View File
@@ -14,7 +14,7 @@ pub enum RectMut<'a> {
impl<'a> RectMut<'a> {
pub unsafe fn wrap(ptr: *mut AVSubtitleRect) -> Self {
match Type::from((*ptr).kind) {
match Type::from((*ptr).type_) {
Type::None => RectMut::None(ptr),
Type::Bitmap => RectMut::Bitmap(BitmapMut::wrap(ptr)),
Type::Text => RectMut::Text(TextMut::wrap(ptr)),
@@ -62,7 +62,7 @@ impl<'a> BitmapMut<'a> {
pub unsafe fn wrap(ptr: *mut AVSubtitleRect) -> Self {
BitmapMut { immutable: Bitmap::wrap(ptr as *const _) }
}
pub unsafe fn as_mut_ptr(&mut self) -> *mut AVSubtitleRect {
self.as_ptr() as *mut _
}
+1 -1
View File
@@ -26,7 +26,7 @@ impl<'a> DeviceIter<'a> {
pub unsafe fn wrap(ctx: *const AVFormatContext) -> Result<Self, Error> {
let mut ptr: *mut AVDeviceInfoList = ptr::null_mut();
match avdevice_list_devices(ctx, &mut ptr) {
match avdevice_list_devices(ctx as *mut _, &mut ptr) {
n if n < 0 =>
Err(Error::from(n)),
+1 -1
View File
@@ -17,7 +17,7 @@ impl<'a> Source<'a> {
impl<'a> Source<'a> {
pub fn failed_requests(&self) -> usize {
unsafe {
av_buffersrc_get_nb_failed_requests(self.ctx.as_ptr()) as usize
av_buffersrc_get_nb_failed_requests(self.ctx.as_ptr() as *mut _) as usize
}
}
+1 -1
View File
@@ -85,7 +85,7 @@ impl Graph {
pub fn dump(&self) -> String {
unsafe {
let ptr = avfilter_graph_dump(self.as_ptr(), ptr::null());
let ptr = avfilter_graph_dump(self.as_ptr() as *mut _, ptr::null());
let cstr = from_utf8_unchecked(CStr::from_ptr((ptr)).to_bytes());
let string = cstr.to_owned();
+1 -1
View File
@@ -27,7 +27,7 @@ pub fn register_all() {
pub fn register(filter: &Filter) -> Result<(), Error> {
unsafe {
match avfilter_register(filter.as_ptr()) {
match avfilter_register(filter.as_ptr() as *mut _) {
0 => Ok(()),
_ => Err(Error::InvalidData),
}
+1 -1
View File
@@ -106,7 +106,7 @@ impl<'a> Best<'a> {
pub fn best<'b>(self, kind: media::Type) -> Option<Stream<'b>> where 'a: 'b {
unsafe {
let mut decoder = ptr::null_mut();
let index = av_find_best_stream(self.context.as_ptr(),
let index = av_find_best_stream(self.context.ptr,
kind.into(), self.wanted as c_int, self.related as c_int,
&mut decoder, 0);
+1 -1
View File
@@ -182,7 +182,7 @@ pub fn dump(ctx: &Input, index: i32, url: Option<&str>) {
let url = url.map(|u| CString::new(u).unwrap());
unsafe {
av_dump_format(ctx.as_ptr(), index,
av_dump_format(ctx.as_ptr() as *mut _, index,
url.map(|u| u.as_ptr()).unwrap_or(ptr::null()), 0);
}
}
+1 -1
View File
@@ -106,7 +106,7 @@ pub fn dump(ctx: &Output, index: i32, url: Option<&str>) {
let url = url.map(|u| CString::new(u).unwrap());
unsafe {
av_dump_format(ctx.as_ptr(), index,
av_dump_format(ctx.as_ptr() as *mut _, index,
url.map(|u| u.as_ptr()).unwrap_or(ptr::null()), 1);
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ impl Output {
let path = CString::new(path.as_ref().as_os_str().to_str().unwrap()).unwrap();
unsafe {
codec::Id::from(av_guess_codec(self.as_ptr(), ptr::null(), path.as_ptr(), ptr::null(), kind.into()))
codec::Id::from(av_guess_codec(self.as_ptr() as *mut _, ptr::null(), path.as_ptr(), ptr::null(), kind.into()))
}
}
+6 -6
View File
@@ -29,11 +29,11 @@ pub fn register_all() {
pub fn register(format: &Format) {
match format {
&Format::Input(ref format) => unsafe {
av_register_input_format(format.as_ptr());
av_register_input_format(format.as_ptr() as *mut _);
},
&Format::Output(ref format) => unsafe {
av_register_output_format(format.as_ptr());
av_register_output_format(format.as_ptr() as *mut _);
}
}
}
@@ -69,7 +69,7 @@ pub fn open<P: AsRef<Path>>(path: &P, format: &Format) -> Result<Context, Error>
match format {
&Format::Input(ref format) => {
match avformat_open_input(&mut ps, path.as_ptr(), format.as_ptr(), ptr::null_mut()) {
match avformat_open_input(&mut ps, path.as_ptr(), format.as_ptr() as *mut _, ptr::null_mut()) {
0 => {
match avformat_find_stream_info(ps, ptr::null_mut()) {
r if r >= 0 => Ok(Context::Input(context::Input::wrap(ps))),
@@ -82,7 +82,7 @@ pub fn open<P: AsRef<Path>>(path: &P, format: &Format) -> Result<Context, Error>
}
&Format::Output(ref format) => {
match avformat_alloc_output_context2(&mut ps, format.as_ptr(), ptr::null(), path.as_ptr()) {
match avformat_alloc_output_context2(&mut ps, format.as_ptr() as *mut _, ptr::null(), path.as_ptr()) {
0 => {
match avio_open(&mut (*ps).pb, path.as_ptr(), AVIO_FLAG_WRITE) {
0 => Ok(Context::Output(context::Output::wrap(ps))),
@@ -105,7 +105,7 @@ pub fn open_with<P: AsRef<Path>>(path: &P, format: &Format, options: Dictionary)
match format {
&Format::Input(ref format) => {
let res = avformat_open_input(&mut ps, path.as_ptr(), format.as_ptr(), &mut opts);
let res = avformat_open_input(&mut ps, path.as_ptr(), format.as_ptr() as *mut _, &mut opts);
Dictionary::own(opts);
@@ -122,7 +122,7 @@ pub fn open_with<P: AsRef<Path>>(path: &P, format: &Format, options: Dictionary)
}
&Format::Output(ref format) => {
match avformat_alloc_output_context2(&mut ps, format.as_ptr(), ptr::null(), path.as_ptr()) {
match avformat_alloc_output_context2(&mut ps, format.as_ptr() as *mut _, ptr::null(), path.as_ptr()) {
0 => {
match avio_open(&mut (*ps).pb, path.as_ptr(), AVIO_FLAG_WRITE) {
0 => Ok(Context::Output(context::Output::wrap(ps))),

Some files were not shown because too many files have changed in this diff Show More