if ( av_pi == null ){
throw( new TranscodeException( "Media Server plugin not found" ));
}
IPCInterface av_ipc = av_pi.getIPC();
String url_str = (String)av_ipc.invoke( "getContentURL", new Object[]{ input });
if ( url_str != null && url_str.length() > 0 ){
source_url = new URL( url_str );
pipe = new TranscodePipeStreamSource( source_url.getHost(), source_url.getPort());
source_url = UrlUtils.setHost( source_url, "127.0.0.1" );
source_url = UrlUtils.setPort( source_url, pipe.getPort());
}
}
if ( source_file == null && source_url == null ){
throw( new TranscodeException( "File doesn't exist" ));
}
final TranscodePipe f_pipe = pipe;
try{
final IPCInterface ipc = plugin_interface.getIPC();
final Object analysis_context;
if ( source_url != null ){
analysis_context = ipc.invoke(
"analyseContent",
new Object[]{
source_url,
profile.getName() });
}else{
analysis_context = ipc.invoke(
"analyseContent",
new Object[]{
source_file,
profile.getName() });
}
final Map<String,Object> result = new HashMap<String, Object>();
final TranscodeProviderAnalysisImpl analysis =
new TranscodeProviderAnalysisImpl()
{
public void
cancel()
{
try{
ipc.invoke( "cancelAnalysis", new Object[]{ analysis_context });
}catch( Throwable e ){
Debug.printStackTrace( e );
}
}
public boolean
foundVideoStream()
{
return( getLongProperty( PT_VIDEO_WIDTH ) > 0 );
}
public boolean
getBooleanProperty(
int property )
{
if ( property == PT_TRANSCODE_REQUIRED ){
return( getBooleanProperty( "xcode_required", true ));
}else{
Debug.out( "Unknown property: " + property );
return( false );
}
}
public void
setBooleanProperty(
int property,
boolean value )
{
if ( property == PT_FORCE_TRANSCODE ){
result.put( "force_xcode", value );
}else{
Debug.out( "Unknown property: " + property );
}
}
public long
getLongProperty(
int property )
{
if ( property == PT_DURATION_MILLIS ){
long duration = getLongProperty( "duration_millis", 0 );
long audio_duration = getLongProperty( "audio_duration_millis", 0 );
if ( duration <= 0 && audio_duration > 0 ){
duration = audio_duration;
}
if ( audio_duration > 0 && audio_duration < duration ){
duration = audio_duration;
}
return( duration );
}else if ( property == PT_VIDEO_WIDTH ){
return( getLongProperty( "video_width", 0 ));
}else if ( property == PT_VIDEO_HEIGHT ){
return( getLongProperty( "video_height", 0 ));
}else if ( property == PT_SOURCE_SIZE ){
return( getLongProperty( "source_size", 0 ));
}else if ( property == PT_ESTIMATED_XCODE_SIZE ){
return( getLongProperty( "estimated_transcoded_size", 0 ));
}else{
Debug.out( "Unknown property: " + property );
return( 0 );
}
}
protected boolean
getBooleanProperty(
String name,
boolean def )
{
Boolean b = (Boolean)result.get( name );
if ( b != null ){
return( b );
}
return( def );
}
protected long
getLongProperty(
String name,
long def )
{
Long l = (Long)result.get( name );
if ( l != null ){
return( l );
}
return( def );
}
public Map<String,Object>
getResult()
{
return( result );
}
};
new AEThread2( "analysisStatus", true )
{
public void
run()
{
try{
while( true ){
try{
Map status = (Map)ipc.invoke( "getAnalysisStatus", new Object[]{ analysis_context });
long state = (Long)status.get( "state" );
if ( state == 0 ){