Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.video.video_decoder

Class EM_SMJPEG_DECODER


Direct ancestors

EM_VIDEO_DECODER, EM_VIDEO_DECODER_CONSTANTS, EM_TIME_SINGLETON, EM_SHARED_BITMAP_FACTORY, EM_AUDIO_CONSTANTS, EM_SHARED_ERROR_HANDLER, EM_SHARED_SCENE, DISPOSABLE

Creation

Features

Invariants

indexing

description

A SMJPEG decoder

date

$Date: 2005/10/28 13:36:58 $

revision

$Revision: 1.25 $

class

EM_SMJPEG_DECODER

inherit

EM_VIDEO_DECODER

create {EM_VIDEO_DECODER_FACTORY}

make

-- init

feature -- Status report

file_name: STRING

-- (From EM_VIDEO_DECODER)

ensure
Result_set: is_loaded implies Result /= Void
has_audio: BOOLEAN

-- (From EM_VIDEO_DECODER)

has_video: BOOLEAN

-- (From EM_VIDEO_DECODER)

height: INTEGER

-- (From EM_DRAWABLE)

ensure
result_not_negative: Result >= 0
is_loaded: BOOLEAN

-- (From EM_VIDEO_DECODER)

is_paused: BOOLEAN

-- (From EM_VIDEO_DECODER)

is_playing: BOOLEAN

-- (From EM_VIDEO_DECODER)

is_size_fixed: BOOLEAN

-- Should Current not scale when drawed?
-- True means that the object will be drawed unscaled
-- but its position (reference_point) will still be transformed correctly
-- if drawed on a transformed scaled coordinate system
-- (This is handled accordingly by draw_object of EM_SURFACE)

-- (From EM_DRAWABLE)

position: INTEGER

-- position

-- (From EM_VIDEO_DECODER)

ensure
in_range: Result >= 0 and Result <= video_length
type: STRING

-- (From EM_VIDEO_DECODER)

ensure
Result_set: Result /= Void and then not Result.is_empty
video_length: INTEGER

-- (From EM_VIDEO_DECODER)

ensure
positive: Result >= 0
width: INTEGER

-- (From EM_DRAWABLE)

ensure
result_not_negative: Result >= 0
x: INTEGER

-- Horizontal position, distance in pixels from left

-- (From EM_DRAWABLE)

y: INTEGER

-- Vertical position, distance in pixels from top

-- (From EM_DRAWABLE)

feature -- Status setting

go_to_position (abs: INTEGER)

-- go to absolute position

-- (From EM_VIDEO_DECODER)

require
loaded: is_loaded
not_stopped: is_playing or is_paused
valid_position: abs >= 0 and abs <= video_length
ensure
position_set: position >= abs and position <= abs + 20
rewind

-- go to beginning

-- (From EM_VIDEO_DECODER)

require
loaded: is_loaded
not_stopped: is_playing or is_paused
ensure
at_start: position <= 20
seek (interval: INTEGER)

-- seek video

-- (From EM_VIDEO_DECODER)

require
loaded: is_loaded
not_stopped: is_playing or is_paused
ensure
seeked: (position >= (old position + interval) \\ video_lengthand (position <= (old position + interval + 20) \\ video_length or old position + interval + 20 >= video_length))or position <= 20 or position = video_length
set_size_fixed (a_boolean: BOOLEAN)

-- Set is_size_fixed to a_boolean.

-- (From EM_DRAWABLE)

ensure
size_fixed_set: is_size_fixed = a_boolean
set_x (x_position: INTEGER)

-- Set x to x_position.

-- (From EM_DRAWABLE)

ensure
x_set: x = x_position
set_x_y (an_x, a_y: INTEGER)

-- Set x to an_x and y to a_y.

-- (From EM_DRAWABLE)

ensure
x_set: x = an_x
y_set: y = a_y
set_y (y_position: INTEGER)

-- Set y to y_position.

-- (From EM_DRAWABLE)

ensure
y_set: y = y_position

feature -- Drawing

draw (a_surface: EM_SURFACE)

-- draw video

-- (From EM_DRAWABLE)

require
a_surface_not_void: a_surface /= Void
draw_part (a_rect: EM_RECT; a_surface: EM_SURFACE)

-- Draw rectangular part of Current defined by a_rect to a_surface.
-- (Subclasses could redefine this feature for providing an implementation
-- with better performance, otherwise its just done per default by
-- transforming and clipping coordinates on a_surface before calling draw).

-- (From EM_DRAWABLE)

require
a_surface_not_void: a_surface /= Void
a_rect_not_void: a_rect /= Void

feature {EM_VIDEO_DECODER_FACTORY} -- Load

load_from_file (file: KI_BINARY_INPUT_FILE)

-- load smjpeg video from file

-- (From EM_VIDEO_DECODER)

require
not_loaded: not is_loaded
file_exist: file /= Void and file.exists
file_readable: file.is_open_read
accept_file: accept_file (file)
valid_file: is_valid_file (file)
ensure
loaded: is_loaded

feature -- Play

play (loops: INTEGER)

-- play video

-- (From EM_VIDEO_DECODER)

require
loaded: is_loaded
not_playing: not is_playing
not_paused: not is_paused
loops_valid: loops >= -1
ensure
playing: is_playing
not_paused: not is_paused

feature -- Pause

pause

-- pause video

-- (From EM_VIDEO_DECODER)

require
loaded: is_loaded
playing: is_playing
ensure
not_playing: not is_playing
paused: is_paused
resume

-- resume playback

-- (From EM_VIDEO_DECODER)

require
loaded: is_loaded
paused: is_paused
ensure
playing: is_playing
not_paused: not is_paused

feature -- Stop

stop

-- stop video

-- (From EM_VIDEO_DECODER)

require
loaded: is_loaded
not_stopped: is_playing or is_paused
ensure
not_playing: not is_playing
not_paused: not is_paused

feature -- Mouse events

events_initialized: BOOLEAN

-- Have events been initialized?

-- (From EM_DRAWABLE)

initialize_events

-- Event initialization.
-- Needs to be called before subscribing for events.

-- (From EM_DRAWABLE)

require
not_yet_initialized: not events_initialized
ensure
events_initialized: events_initialized
mouse_button_down_event_initialized: mouse_button_down_event /= Void
mouse_button_up_event_initialized: mouse_button_up_event /= Void
mouse_motion_event_initialized: mouse_motion_event /= Void
mouse_button_down_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button down event,
-- gets published when the mouse button is pressed over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

-- (From EM_DRAWABLE)

mouse_button_up_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

-- (From EM_DRAWABLE)

mouse_motion_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEMOTION_EVENT is passed as argument

-- (From EM_DRAWABLE)

publish_mouse_event (a_mouse_event: EM_MOUSE_EVENT)

-- Publish mouse event when a_mouse_event occured on Current.
-- Descendants should redefine this feature
-- for only catching and publishing their mouse events when mouse pointer
-- is realy inside object or for
-- distributing mouse events to child objects.

-- (From EM_DRAWABLE)

require
a_mouse_event_not_void: a_mouse_event /= Void

feature {EM_VIDEO_DECODER_FACTORY} -- Request

accept_file (file: KI_BINARY_INPUT_FILE): BOOLEAN

-- accept file

-- (From EM_VIDEO_DECODER)

require
file_exist: file /= Void and then file.exists
file_open_read: file.is_open_read
is_valid_file (file: KI_BINARY_INPUT_FILE): BOOLEAN

-- is file a valid file

-- (From EM_VIDEO_DECODER)

require
file_exist: file /= Void and then file.exists
file_open_read: file.is_open_read
accepted: accept_file (file)

feature -- Event

on_stop: EM_EVENT_TYPE [TUPLE]

-- (From EM_VIDEO_DECODER)

ensure
exist: Result /= Void

feature -- Queries

bounding_box: EM_ORTHOGONAL_RECTANGLE

-- Orthogonal rectangle surrounding Current; (i.e. usefull
-- for visibility testing if it intersects with
-- coordinate_area of EM_SURFACE) TODO: We create a new
-- one on each call. Maybe there is a more efficient way to
-- do that?

-- (From EM_DRAWABLE)

ensure
result_not_void: Result /= Void
reference_point: EM_VECTOR_2D

-- Reference point of Current relative to which it should be positioned.
-- (i.e. important when drawn on a scaled coordinate system and is_size_fixed is True)

-- (From EM_DRAWABLE)

ensure
result_not_void: Result /= Void

invariant

mutex_exist: mutex /= Void
picture_loaded: picture /= Void
file_loaded: is_loaded implies video_file.is_open_read
video_settings_set: has_video implies video_frames > 0 and video_encoding = em_smjpeg_video_jpeg
audio_settings_set: has_audio implies audio_rate > 0 and audio_bits_per_sample > 0 and audio_channels > 0 and audio_subsystem.is_enabled
valid_audio_encoding: has_audio implies audio_encoding = em_smjpeg_audio_adpcm or audio_encoding = em_smjpeg_audio_none
mixer_opend_correct: has_audio implies audio_subsystem.mixer.frequency = audio_rate and audio_subsystem.mixer.output_channel = audio_channels

at_most_one_state: not (is_paused and is_playing)
has_video_correct: has_video implies width > 0 and height > 0

-- From EM_DRAWABLE
mouse_button_down_event_initialized: events_initialized implies mouse_button_down_event /= Void
mouse_button_up_event_initialized: events_initialized implies mouse_button_up_event /= Void
mouse_motion_event_initialized: events_initialized implies mouse_motion_event /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

has_running_scene_definition: has_running_scene implies running_scene /= Void

end