fn new(texture_creator: &'a TextureCreator<WindowContext>, width: usize, height: usize, len: usize) -> Self {
let mut pool = Vec::with_capacity(len);
for _ in 0..len + 1 {
fn new(texture_creator: &'a TextureCreator<WindowContext>, width: usize, height: usize, len: usize) -> Self {
let mut pool = Vec::with_capacity(len);
for _ in 0..len + 1 {
- let rgb_tex = texture_creator.create_texture_streaming(PixelFormatEnum::RGB24, width as u32, height as u32).unwrap();
- let yuv_tex = texture_creator.create_texture_streaming(PixelFormatEnum::IYUV, ((width + 1) & !1) as u32, ((height + 1) & !1) as u32).unwrap();
+ let rgb_tex = texture_creator.create_texture_streaming(PixelFormatEnum::RGB24, width as u32, height as u32).expect("failed to create RGB texture");
+ let yuv_tex = texture_creator.create_texture_streaming(PixelFormatEnum::IYUV, ((width + 1) & !1) as u32, ((height + 1) & !1) as u32).expect("failed to create YUV texture");
pool.push(DispFrame{ ts: 0, is_yuv: false, valid: false, rgb_tex, yuv_tex });
}
pool[len].is_yuv = false;
pool[len].rgb_tex.with_lock(None, |buffer: &mut [u8], _pitch: usize| {
for el in buffer.iter_mut() { *el = 0; }
pool.push(DispFrame{ ts: 0, is_yuv: false, valid: false, rgb_tex, yuv_tex });
}
pool[len].is_yuv = false;
pool[len].rgb_tex.with_lock(None, |buffer: &mut [u8], _pitch: usize| {
for el in buffer.iter_mut() { *el = 0; }
Self { pool, first_ts: 0, last_ts: 0, start: 0, end: 0, len, width, height }
}
Self { pool, first_ts: 0, last_ts: 0, start: 0, end: 0, len, width, height }
}
if osd.is_active() {
self.pool[self.len].yuv_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_yuv(buffer, pitch);
if osd.is_active() {
self.pool[self.len].yuv_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_yuv(buffer, pitch);
}
&self.pool[self.len].yuv_tex
} else {
if osd.is_active() {
self.pool[self.len].rgb_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_rgb(buffer, pitch);
}
&self.pool[self.len].yuv_tex
} else {
if osd.is_active() {
self.pool[self.len].rgb_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_rgb(buffer, pitch);
if osd.is_active() {
frm.yuv_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_yuv(buffer, pitch);
if osd.is_active() {
frm.yuv_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_yuv(buffer, pitch);
}
&frm.yuv_tex
} else {
if osd.is_active() {
frm.rgb_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_rgb(buffer, pitch);
}
&frm.yuv_tex
} else {
if osd.is_active() {
frm.rgb_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| {
osd.draw_rgb(buffer, pitch);
- let sdl_context = sdl2::init().unwrap();
- let vsystem = sdl_context.video().unwrap();
- let asystem = sdl_context.audio().unwrap();
+ let sdl_context = sdl2::init().expect("SDL2 init failure");
+ let vsystem = sdl_context.video().expect("video subsystem init failure");
+ let asystem = sdl_context.audio().expect("audio subsystem init failure");
vsystem.disable_screen_saver();
let acontrol = AudioControl::new(None, None, &asystem);
let vcontrol = VideoControl::new(None, 0, 0, 0, 0);
vsystem.disable_screen_saver();
let acontrol = AudioControl::new(None, None, &asystem);
let vcontrol = VideoControl::new(None, 0, 0, 0, 0);
}
}
fn seek(&mut self, off: u64, fwd: bool, dmx: &mut Demuxer, disp_queue: &mut DispQueue) -> Result<(), ()> {
}
}
fn seek(&mut self, off: u64, fwd: bool, dmx: &mut Demuxer, disp_queue: &mut DispQueue) -> Result<(), ()> {
let ret = create_demuxer(dmx_fact, &mut br);
if ret.is_err() {
println!("error creating demuxer");
let ret = create_demuxer(dmx_fact, &mut br);
if ret.is_err() {
println!("error creating demuxer");
dsupp.pool_u8 = NAVideoBufferPool::new(reorder_depth);
dsupp.pool_u16 = NAVideoBufferPool::new(reorder_depth);
dsupp.pool_u32 = NAVideoBufferPool::new(reorder_depth);
dsupp.pool_u8 = NAVideoBufferPool::new(reorder_depth);
dsupp.pool_u16 = NAVideoBufferPool::new(reorder_depth);
dsupp.pool_u32 = NAVideoBufferPool::new(reorder_depth);
video_dec = Some(DecoderStuff{ dsupp, dec: DecoderType::Video(dec, reord) });
self.video_str = str_id;
let (tbn, tbd) = s.get_timebase();
video_dec = Some(DecoderStuff{ dsupp, dec: DecoderType::Video(dec, reord) });
self.video_str = str_id;
let (tbn, tbd) = s.get_timebase();
let mut dec = (decfunc)();
let mut dsupp = Box::new(NADecoderSupport::new());
ainfo = info.get_properties().get_audio_info();
let mut dec = (decfunc)();
let mut dsupp = Box::new(NADecoderSupport::new());
ainfo = info.get_properties().get_audio_info();
} else {
"NihAV player".to_owned()
};
let mut builder = self.vsystem.window(&wname, width as u32, height as u32);
let window = if let (Some(xpos), Some(ypos)) = (self.xpos, self.ypos) {
} else {
"NihAV player".to_owned()
};
let mut builder = self.vsystem.window(&wname, width as u32, height as u32);
let window = if let (Some(xpos), Some(ypos)) = (self.xpos, self.ypos) {
let texture_creator = canvas.texture_creator();
let mut disp_q = DispQueue::new(&texture_creator, width, height, if self.has_video { FRAME_QUEUE_LEN } else { 0 });
if !self.has_video {
canvas.clear();
let texture_creator = canvas.texture_creator();
let mut disp_q = DispQueue::new(&texture_creator, width, height, if self.has_video { FRAME_QUEUE_LEN } else { 0 });
if !self.has_video {
canvas.clear();