|
From: <mar...@us...> - 2003-03-17 02:57:06
|
Update of /cvsroot/madsserv/madsserv/src/server/processor
In directory sc8-pr-cvs1:/tmp/cvs-serv14897
Modified Files:
Reencode.java ThreadReencode.java
Log Message:
nouveau mode de choix des formats implemente
Index: Reencode.java
===================================================================
RCS file: /cvsroot/madsserv/madsserv/src/server/processor/Reencode.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Reencode.java 14 Mar 2003 03:26:19 -0000 1.12
--- Reencode.java 17 Mar 2003 02:57:02 -0000 1.13
***************
*** 22,26 ****
* Classe Reencode
*/
! public class Reencode implements ControllerListener {
/**
--- 22,27 ----
* Classe Reencode
*/
! public class Reencode
! implements ControllerListener {
/**
***************
*** 37,41 ****
private int clientId = -1; // Numero du client demandeur.
private MediaLocator inputML = null; // MediaLocator du fichier a convertir.
- private DataSource inputDS = null; // DataSource contenant le fichier a convertir.
private TrackControl[] inputTC = null; // TrackControl permettant d'acceder aux differentes pistes du media.
private Format[] inputFormat = null; // Vecteur de Format pour stocker les formats des pistes.
--- 38,41 ----
***************
*** 44,49 ****
private AudioFormat reencodingAudioFormat = null; // Format audio de reencodage du fichier.
private VideoFormat reencodingVideoFormat = null; // Format video de reencodage du fichier.
private Time startTime = new Time(0); // Instant de debut de conversion.
!
/**
--- 44,50 ----
private AudioFormat reencodingAudioFormat = null; // Format audio de reencodage du fichier.
private VideoFormat reencodingVideoFormat = null; // Format video de reencodage du fichier.
+ private Time duration = new Time(1); // Duree du fichier.
private Time startTime = new Time(0); // Instant de debut de conversion.
! private Format[][] supportedFormats = null; // Formats de reencodage suppportes par le processor.
/**
***************
*** 52,61 ****
* @param inputURL l'URL demande par le client
*/
! Reencode(int clientId, String inputURL)
! {
// Stockage de l'ID du client correspondant a l'instantiation.
this.clientId = clientId;
! if(this.clientId < 0)
! {
System.err.println("L'ID du client n'a pas ete transmis correctement.");
System.exit(0);
--- 53,60 ----
* @param inputURL l'URL demande par le client
*/
! Reencode(int clientId, String inputURL) {
// Stockage de l'ID du client correspondant a l'instantiation.
this.clientId = clientId;
! if (this.clientId < 0) {
System.err.println("L'ID du client n'a pas ete transmis correctement.");
System.exit(0);
***************
*** 63,68 ****
// Stockage de l'URL demande correspondant a l'instantiation.
this.inputURL = inputURL;
! if(this.inputURL == null)
! {
System.err.println("L'URL a lire n'a pas ete transmis correctement.");
System.exit(0);
--- 62,66 ----
// Stockage de l'URL demande correspondant a l'instantiation.
this.inputURL = inputURL;
! if (this.inputURL == null) {
System.err.println("L'URL a lire n'a pas ete transmis correctement.");
System.exit(0);
***************
*** 71,94 ****
// Conversion de l'URL en MediaLocator.
! if((inputML = createMediaLocator(inputURL)) == null)
! {
! System.err.println("Impossible de construire le MediaLocator a partir de : " + inputURL);
System.exit(0);
}
// Determination des formats d'origine du fichier demande.
// Pour cela, on cree un Processor que l'on place dans l'etat configure.
- // Source inspire de la classe Transcode publiee par Sun.
- // http://java.sun.com/products/java-media/jmf/2.1.1/solutions/Transcode.html
Processor p = null;
! try
! {
p = Manager.createProcessor(inputML);
System.err.println("- create processor for: " + inputML);
}
! catch (Exception e)
! {
! System.err.println("Yikes! Cannot create a processor from the given url: " + e);
}
--- 69,98 ----
// Conversion de l'URL en MediaLocator.
! if ( (inputML = createMediaLocator(inputURL)) == null) {
! System.err.println(
! "Impossible de construire le MediaLocator a partir de : " + inputURL);
System.exit(0);
}
+ }
+ /**
+ * Methode retournant les formats de reencodage supportes par le processor.
+ * On en profite aussi pour recuperer les formats originaux et la duree du media.
+ * Source inspire de la classe Transcode publiee par Sun.
+ * http://java.sun.com/products/java-media/jmf/2.1.1/solutions/Transcode.html
+ * @return les formats de reencodage supportes par le processor
+ */
+ public Format[][] getSupportedFormats() {
// Determination des formats d'origine du fichier demande.
// Pour cela, on cree un Processor que l'on place dans l'etat configure.
Processor p = null;
! try {
p = Manager.createProcessor(inputML);
System.err.println("- create processor for: " + inputML);
}
! catch (Exception e) {
! System.err.println(
! "Yikes! Cannot create a processor from the given url: " + e);
}
***************
*** 97,136 ****
// Put the Processor into configured state.
p.configure();
! if (!waitForState(p, p.Configured))
! {
System.err.println("Failed to configure the processor.");
}
// A l'aide de TrackControl, on accede aux differentes pistes du media.
! try
! {
! if ( (inputTC = p.getTrackControls()) == null)
! {
System.err.println("Il n'y a aucune piste dans le fichier !");
}
! else
! {
! if(inputTC.length > 2)
! {
System.err.println("Il y a trop de pistes dans le fichier !");
}
! else
! {
inputFormat = new Format[inputTC.length];
! if(inputTC.length == 1)
! {
inputFormat[0] = inputTC[0].getFormat();
! System.err.println("Il n'y a qu'une seule piste");
! setOriginalAudioFormat( (AudioFormat) inputFormat[0]); //FIXME si video sans son
}
! else // Il y a deux pistes, la video est la premiere
! {
inputFormat[0] = inputTC[0].getFormat();
- System.err.println("Format piste n 1 : " + inputFormat[0].toString());
setOriginalVideoFormat( (VideoFormat) inputFormat[0]);
inputFormat[1] = inputTC[1].getFormat();
- System.err.println("Format piste n 2 : " + inputFormat[1].toString());
setOriginalAudioFormat( (AudioFormat) inputFormat[1]);
! multiMedia = true;
}
}
--- 101,145 ----
// Put the Processor into configured state.
p.configure();
! if (!waitForState(p, p.Configured)) {
System.err.println("Failed to configure the processor.");
}
// A l'aide de TrackControl, on accede aux differentes pistes du media.
! try {
! inputTC = p.getTrackControls();
! ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
! p.setContentDescriptor(cd);
!
! if (inputTC == null) {
System.err.println("Il n'y a aucune piste dans le fichier !");
}
! else {
! if (inputTC.length > 2) {
System.err.println("Il y a trop de pistes dans le fichier !");
}
! else {
inputFormat = new Format[inputTC.length];
! if (inputTC.length == 1) {
inputFormat[0] = inputTC[0].getFormat();
! setOriginalAudioFormat( (AudioFormat) inputFormat[0]);
}
! else { // Il y a deux pistes, la video est la premiere
inputFormat[0] = inputTC[0].getFormat();
setOriginalVideoFormat( (VideoFormat) inputFormat[0]);
inputFormat[1] = inputTC[1].getFormat();
setOriginalAudioFormat( (AudioFormat) inputFormat[1]);
! }
!
! // Les formats supportes sont stockes dans supportedFormat[][]
! supportedFormats = new Format[inputTC.length][];
! for (int i = 0; i < inputTC.length; i++) {
! if (i == 1) {
! multiMedia = true;
! }
! supportedFormats[i] = inputTC[i].getSupportedFormats();
! for (int j = 0; j < supportedFormats[i].length; j++) {
! System.out.println("Piste " + i + ", format supporte " + j +
! " : " + supportedFormats[i][j].toString());
! }
}
}
***************
*** 139,143 ****
--- 148,161 ----
catch (NotConfiguredError e) {}
+ // On recupere la duree du media (il faut que le processor soit started)
+ p.start();
+ duration = p.getDuration();
+ p.stop();
+
p.removeControllerListener(this);
+ p.close();
+ p = null;
+
+ return (supportedFormats);
}
***************
*** 145,152 ****
* Lancement de la conversion
*/
! public void start()
! {
! if(!reencoding)
! {
if (multiMedia) { // Fichier audio et video
currentThreadReencode = new ThreadReencode(inputML,
--- 163,168 ----
* Lancement de la conversion
*/
! public void start() {
! if (!reencoding) {
if (multiMedia) { // Fichier audio et video
currentThreadReencode = new ThreadReencode(inputML,
***************
*** 161,166 ****
streamingRef.setNewStreams(currentThreadReencode.getOutput());
}
! else
! {
formerThreadReencode = currentThreadReencode;
if (multiMedia) { // Fichier audio et video
--- 177,181 ----
streamingRef.setNewStreams(currentThreadReencode.getOutput());
}
! else {
formerThreadReencode = currentThreadReencode;
if (multiMedia) { // Fichier audio et video
***************
*** 191,203 ****
* @return 0 si arret du precedent thread
*/
! public int stopFormerThreadReencode()
! {
! if(formerThreadReencode == null)
! {
! System.err.println("Le precedent ThreadReencode est deja arrete ou n'a jamais ete affecte.");
return -1;
}
! else // on arrete le processor et met la reference du ThreadReencode precedent a null
! {
formerThreadReencode.stopProcessing();
formerThreadReencode = null;
--- 206,216 ----
* @return 0 si arret du precedent thread
*/
! public int stopFormerThreadReencode() {
! if (formerThreadReencode == null) {
! System.err.println(
! "Le precedent ThreadReencode est deja arrete ou n'a jamais ete affecte.");
return -1;
}
! else { // on arrete le processor et met la reference du ThreadReencode precedent a null
formerThreadReencode.stopProcessing();
formerThreadReencode = null;
***************
*** 210,215 ****
* @return l'ID du client correspondant au module instancie
*/
! public int getClientId()
! {
return this.clientId;
}
--- 223,227 ----
* @return l'ID du client correspondant au module instancie
*/
! public int getClientId() {
return this.clientId;
}
***************
*** 219,224 ****
* @return le format video original du fichier
*/
! public VideoFormat getOriginalVideoFormat()
! {
return this.originalVideoFormat;
}
--- 231,235 ----
* @return le format video original du fichier
*/
! public VideoFormat getOriginalVideoFormat() {
return this.originalVideoFormat;
}
***************
*** 228,233 ****
* @return le format audio original du fichier
*/
! public AudioFormat getOriginalAudioFormat()
! {
return this.originalAudioFormat;
}
--- 239,243 ----
* @return le format audio original du fichier
*/
! public AudioFormat getOriginalAudioFormat() {
return this.originalAudioFormat;
}
***************
*** 237,244 ****
* @param originalVideoFormat le format video original du fichier
*/
! private void setOriginalVideoFormat(VideoFormat originalVideoFormat)
! {
this.originalVideoFormat = originalVideoFormat;
! System.out.println("Format video original du fichier : " + this.originalVideoFormat.toString());
}
--- 247,254 ----
* @param originalVideoFormat le format video original du fichier
*/
! private void setOriginalVideoFormat(VideoFormat originalVideoFormat) {
this.originalVideoFormat = originalVideoFormat;
! System.out.println("Format video original du fichier : " +
! this.originalVideoFormat.toString());
}
***************
*** 247,272 ****
* @param originalAudioFormat le format audio original du fichier
*/
! private void setOriginalAudioFormat(AudioFormat originalAudioFormat)
! {
this.originalAudioFormat = originalAudioFormat;
! System.out.println("Format audio original du fichier : " + this.originalAudioFormat.toString());
}
/**
! * Definit le format vidéo de reencodage du fichier demande.
! * @param reencodingVideoFormat le nouveau format vidéo de réencodage
* @return 0 si mise a jour effectuee
* @return -1 si erreur
*/
! public int setReencodingVideoFormat(VideoFormat reencodingVideoFormat)
! {
! if(reencodingVideoFormat != null)
! {
this.reencodingVideoFormat = reencodingVideoFormat;
! System.err.println("Nouveau format video recu : " + reencodingVideoFormat.toString());
return 0;
}
! else
! {
System.err.println("Pas de nouveau format video recu !");
return -1;
--- 257,288 ----
* @param originalAudioFormat le format audio original du fichier
*/
! private void setOriginalAudioFormat(AudioFormat originalAudioFormat) {
this.originalAudioFormat = originalAudioFormat;
! System.out.println("Format audio original du fichier : " +
! this.originalAudioFormat.toString());
}
/**
! * Methode retournant la duree du fichier.
! * @return duree du fichier en secondes
! */
! public double getMediaLength() {
! return (duration.getSeconds());
! }
!
! /**
! * Definit le format video de reencodage du fichier demande.
! * @param reencodingVideoFormat le nouveau format video de reencodage
* @return 0 si mise a jour effectuee
* @return -1 si erreur
*/
! public int setReencodingVideoFormat(VideoFormat reencodingVideoFormat) {
! if (reencodingVideoFormat != null) {
this.reencodingVideoFormat = reencodingVideoFormat;
! System.err.println("Nouveau format video recu : " +
! reencodingVideoFormat.toString());
return 0;
}
! else {
System.err.println("Pas de nouveau format video recu !");
return -1;
***************
*** 276,293 ****
/**
* Definit le format audio de reencodage du fichier demande.
! * @param reencodingAudioFormat le nouveau format audio de réencodage
* @return 0 si mise a jour effectuee
* @return -1 si erreur
*/
! public int setReencodingAudioFormat(AudioFormat reencodingAudioFormat)
! {
! if(reencodingAudioFormat != null)
! {
this.reencodingAudioFormat = reencodingAudioFormat;
! System.err.println("Nouveau format audio recu : " + reencodingAudioFormat.toString());
return 0;
}
! else
! {
System.err.println("Pas de nouveau format audio recu !");
return -1;
--- 292,307 ----
/**
* Definit le format audio de reencodage du fichier demande.
! * @param reencodingAudioFormat le nouveau format audio de reencodage
* @return 0 si mise a jour effectuee
* @return -1 si erreur
*/
! public int setReencodingAudioFormat(AudioFormat reencodingAudioFormat) {
! if (reencodingAudioFormat != null) {
this.reencodingAudioFormat = reencodingAudioFormat;
! System.err.println("Nouveau format audio recu : " +
! reencodingAudioFormat.toString());
return 0;
}
! else {
System.err.println("Pas de nouveau format audio recu !");
return -1;
***************
*** 299,304 ****
* @param startTime l'instant du changement de conversion
*/
! public void setReencodingTime(Time startTime)
! {
this.startTime = startTime;
}
--- 313,317 ----
* @param startTime l'instant du changement de conversion
*/
! public void setReencodingTime(Time startTime) {
this.startTime = startTime;
}
***************
*** 308,314 ****
* @param streamingRef la reference du module Streaming correspondant au meme client
*/
! public void setStreamingRef(Streaming streamingRef)
! {
! this.streamingRef = streamingRef;
}
--- 321,326 ----
* @param streamingRef la reference du module Streaming correspondant au meme client
*/
! public void setStreamingRef(Streaming streamingRef) {
! this.streamingRef = streamingRef;
}
***************
*** 317,326 ****
* @param transitionRef la reference du module Transition correspondant au meme client
*/
! public void setTransitionRef(Transition transitionRef)
! {
! this.transitionRef = transitionRef;
}
-
/**
* Cree un media locator a partir de l'URL (String) demandee.
--- 329,336 ----
* @param transitionRef la reference du module Transition correspondant au meme client
*/
! public void setTransitionRef(Transition transitionRef) {
! this.transitionRef = transitionRef;
}
/**
* Cree un media locator a partir de l'URL (String) demandee.
***************
*** 330,347 ****
* @return un MediaLocator
*/
! static MediaLocator createMediaLocator(String url)
! {
MediaLocator ml;
! if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
return ml;
if (url.startsWith(File.separator)) {
! if ((ml = new MediaLocator("file:" + url)) != null)
return ml;
! } else {
! String file = "file:" + System.getProperty("user.dir") + File.separator + url;
! if ((ml = new MediaLocator(file)) != null)
return ml;
}
--- 340,361 ----
* @return un MediaLocator
*/
! static MediaLocator createMediaLocator(String url) {
MediaLocator ml;
! if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null) {
return ml;
+ }
if (url.startsWith(File.separator)) {
! if ( (ml = new MediaLocator("file:" + url)) != null) {
return ml;
! }
! }
! else {
! String file = "file:" + System.getProperty("user.dir") + File.separator +
! url;
! if ( (ml = new MediaLocator(file)) != null) {
return ml;
+ }
}
***************
*** 364,370 ****
synchronized (waitSync) {
try {
! while (p.getState() < state && stateTransitionOK)
waitSync.wait();
! } catch (Exception e) {}
}
return stateTransitionOK;
--- 378,386 ----
synchronized (waitSync) {
try {
! while (p.getState() < state && stateTransitionOK) {
waitSync.wait();
! }
! }
! catch (Exception e) {}
}
return stateTransitionOK;
***************
*** 385,413 ****
waitSync.notifyAll();
}
! } else if (evt instanceof ResourceUnavailableEvent) {
synchronized (waitSync) {
stateTransitionOK = false;
waitSync.notifyAll();
}
! } else if (evt instanceof EndOfMediaEvent) {
evt.getSourceController().close();
! } else if (evt instanceof MediaTimeSetEvent) {
System.err.println("- mediaTime set: " +
! ((MediaTimeSetEvent)evt).getMediaTime().getSeconds());
! } else if (evt instanceof StopAtTimeEvent) {
System.err.println("- stop at time: " +
! ((StopAtTimeEvent)evt).getMediaTime().getSeconds());
evt.getSourceController().close();
}
}
! public int stop()
! {
! if(formerThreadReencode == null)
! {
! System.err.println("Le precedent ThreadReencode est deja arrete ou n'a jamais ete affecte.");
}
! else // on arrete le processor et met la reference du ThreadReencode precedent a null
! {
formerThreadReencode.stopProcessing();
formerThreadReencode = null;
--- 401,431 ----
waitSync.notifyAll();
}
! }
! else if (evt instanceof ResourceUnavailableEvent) {
synchronized (waitSync) {
stateTransitionOK = false;
waitSync.notifyAll();
}
! }
! else if (evt instanceof EndOfMediaEvent) {
evt.getSourceController().close();
! }
! else if (evt instanceof MediaTimeSetEvent) {
System.err.println("- mediaTime set: " +
! ( (MediaTimeSetEvent) evt).getMediaTime().getSeconds());
! }
! else if (evt instanceof StopAtTimeEvent) {
System.err.println("- stop at time: " +
! ( (StopAtTimeEvent) evt).getMediaTime().getSeconds());
evt.getSourceController().close();
}
}
! public int stop() {
! if (formerThreadReencode == null) {
! System.err.println(
! "Le precedent ThreadReencode est deja arrete ou n'a jamais ete affecte.");
}
! else { // on arrete le processor et met la reference du ThreadReencode precedent a null
formerThreadReencode.stopProcessing();
formerThreadReencode = null;
***************
*** 418,420 ****
}
! }
--- 436,438 ----
}
! }
\ No newline at end of file
Index: ThreadReencode.java
===================================================================
RCS file: /cvsroot/madsserv/madsserv/src/server/processor/ThreadReencode.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ThreadReencode.java 14 Mar 2003 03:26:19 -0000 1.6
--- ThreadReencode.java 17 Mar 2003 02:57:03 -0000 1.7
***************
*** 22,31 ****
import com.sun.media.rtp.*;
-
/**
* Classe ThreadReencode
*/
! class ThreadReencode extends Thread
! {
/**
* Champs de la classe ThreadReencode
--- 22,30 ----
import com.sun.media.rtp.*;
/**
* Classe ThreadReencode
*/
! class ThreadReencode
! extends Thread {
/**
* Champs de la classe ThreadReencode
***************
*** 47,53 ****
* @param reencodeRef reference du module Reencode pere
*/
! public ThreadReencode (MediaLocator inputML, AudioFormat reencodingAudioFormat,
! Time startTime, Reencode reencodeRef)
! {
this.inputML = inputML;
this.reencodingAudioFormat = reencodingAudioFormat;
--- 46,51 ----
* @param reencodeRef reference du module Reencode pere
*/
! public ThreadReencode(MediaLocator inputML, AudioFormat reencodingAudioFormat,
! Time startTime, Reencode reencodeRef) {
this.inputML = inputML;
this.reencodingAudioFormat = reencodingAudioFormat;
***************
*** 65,72 ****
* @param reencodeRef reference du module Reencode pere
*/
! public ThreadReencode (MediaLocator inputML, AudioFormat reencodingAudioFormat,
! VideoFormat reencodingVideoFormat, Time startTime,
! Reencode reencodeRef)
! {
this.inputML = inputML;
this.reencodingAudioFormat = reencodingAudioFormat;
--- 63,69 ----
* @param reencodeRef reference du module Reencode pere
*/
! public ThreadReencode(MediaLocator inputML, AudioFormat reencodingAudioFormat,
! VideoFormat reencodingVideoFormat, Time startTime,
! Reencode reencodeRef) {
this.inputML = inputML;
this.reencodingAudioFormat = reencodingAudioFormat;
***************
*** 83,88 ****
* http://java.sun.com/products/java-media/jmf/2.1.1/solutions/Transcode.html
*/
! public void run()
! {
String resultat;
--- 80,84 ----
* http://java.sun.com/products/java-media/jmf/2.1.1/solutions/Transcode.html
*/
! public void run() {
String resultat;
***************
*** 101,106 ****
private String createProcessor() {
! if (inputML == null)
return "Locator is null";
DataSource ds;
--- 97,103 ----
private String createProcessor() {
! if (inputML == null) {
return "Locator is null";
+ }
DataSource ds;
***************
*** 109,113 ****
try {
ds = javax.media.Manager.createDataSource(inputML);
! } catch (Exception e) {
return "Couldn't create DataSource";
}
--- 106,111 ----
try {
ds = javax.media.Manager.createDataSource(inputML);
! }
! catch (Exception e) {
return "Couldn't create DataSource";
}
***************
*** 116,122 ****
try {
processor = javax.media.Manager.createProcessor(ds);
! } catch (NoProcessorException npe) {
return "Couldn't create processor";
! } catch (IOException ioe) {
return "IOException creating processor";
}
--- 114,122 ----
try {
processor = javax.media.Manager.createProcessor(ds);
! }
! catch (NoProcessorException npe) {
return "Couldn't create processor";
! }
! catch (IOException ioe) {
return "IOException creating processor";
}
***************
*** 124,136 ****
// Wait for it to configure
boolean result = waitForState(processor, Processor.Configured);
! if (result == false)
return "Couldn't configure processor";
// Get the tracks from the processor
! TrackControl [] tracks = processor.getTrackControls();
// Do we have atleast one track?
! if (tracks == null || tracks.length < 1)
return "Couldn't find tracks in processor";
// Set the output content descriptor to RAW_RTP
--- 124,138 ----
// Wait for it to configure
boolean result = waitForState(processor, Processor.Configured);
! if (result == false) {
return "Couldn't configure processor";
+ }
// Get the tracks from the processor
! TrackControl[] tracks = processor.getTrackControls();
// Do we have atleast one track?
! if (tracks == null || tracks.length < 1) {
return "Couldn't find tracks in processor";
+ }
// Set the output content descriptor to RAW_RTP
***************
*** 141,184 ****
Format supported[];
! Format chosen;
! Format finalchosen;
! boolean atLeastOneTrack = false;
!
! // Program the tracks.
! for (int i = 0; i < tracks.length; i++) {
! Format format = tracks[i].getFormat();
! if (tracks[i].isEnabled()) {
! System.out.println("Track " + i + " is enabled");
! supported = tracks[i].getSupportedFormats();
!
! // We've set the output content to the RAW_RTP.
! // So all the supported formats should work with RTP.
! // We'll just pick the first one.
! if (supported.length > 0) {
! for(int j=0;j<supported.length;j++)
! System.out.println("Format supporte n" + j + " : " + supported[j].toString());
! if (supported[0] instanceof VideoFormat) {
! // For video formats, we should double check the
! // sizes since not all formats work in all sizes.
! chosen = checkForVideoSizes(tracks[i].getFormat(),
! supported[0]);
! } else {
! chosen = supported[0];
! }
! tracks[i].setFormat(chosen);
! System.err.println("Track " + i + " is set to transmit as:");
! System.err.println(" " + chosen);
! atLeastOneTrack = true;
! } else
! tracks[i].setEnabled(false);
! } else {
! tracks[i].setEnabled(false);
! System.out.println("Track " + i + " isn't enabled");
! }
}
-
- if (!atLeastOneTrack)
- return "Couldn't set any of the tracks to a valid RTP format";
// Realize the processor. This will internally create a flow
--- 143,158 ----
Format supported[];
! Format finalReencodingVideoFormat;
! // On indique au processor les formats de reencodage.
! if (!reencodeRef.multiMedia) {
! tracks[0].setFormat(reencodingAudioFormat); // 1 piste audio
! }
! else { // Le fichier est multimedia
! finalReencodingVideoFormat = checkForVideoSizes(tracks[0].getFormat(),
! reencodingVideoFormat);
! tracks[0].setFormat(finalReencodingVideoFormat);
! tracks[1].setFormat(reencodingAudioFormat);
}
// Realize the processor. This will internally create a flow
***************
*** 186,191 ****
// audio frames.
result = waitForState(processor, Controller.Realized);
! if (result == false)
return "Couldn't realize processor";
// Set the JPEG quality to .5.
--- 160,166 ----
// audio frames.
result = waitForState(processor, Controller.Realized);
! if (result == false) {
return "Couldn't realize processor";
+ }
// Set the JPEG quality to .5.
***************
*** 193,198 ****
// Commencer a encoder a partir de l'instant voulu
! if (startTime.getSeconds() > 0)
! {
processor.setMediaTime(startTime);
}
--- 168,172 ----
// Commencer a encoder a partir de l'instant voulu
! if (startTime.getSeconds() > 0) {
processor.setMediaTime(startTime);
}
***************
*** 214,219 ****
// and program it to output JPEG/RTP
result = createProcessor();
! if (result != null)
return result;
// Start the transmission
--- 188,194 ----
// and program it to output JPEG/RTP
result = createProcessor();
! if (result != null) {
return result;
+ }
// Start the transmission
***************
*** 244,248 ****
int width, height;
! Dimension size = ((VideoFormat)original).getSize();
Format jpegFmt = new Format(VideoFormat.JPEG_RTP);
Format h263Fmt = new Format(VideoFormat.H263_RTP);
--- 219,223 ----
int width, height;
! Dimension size = ( (VideoFormat) original).getSize();
Format jpegFmt = new Format(VideoFormat.JPEG_RTP);
Format h263Fmt = new Format(VideoFormat.H263_RTP);
***************
*** 251,270 ****
// For JPEG, make sure width and height are divisible by 8.
width = (size.width % 8 == 0 ? size.width :
! (int)(size.width / 8) * 8);
height = (size.height % 8 == 0 ? size.height :
! (int)(size.height / 8) * 8);
! } else if (supported.matches(h263Fmt)) {
// For H.263, we only support some specific sizes.
if (size.width < 128) {
width = 128;
height = 96;
! } else if (size.width < 176) {
width = 176;
height = 144;
! } else {
width = 352;
height = 288;
}
! } else {
// We don't know this particular format. We'll just
// leave it alone then.
--- 226,249 ----
// For JPEG, make sure width and height are divisible by 8.
width = (size.width % 8 == 0 ? size.width :
! (int) (size.width / 8) * 8);
height = (size.height % 8 == 0 ? size.height :
! (int) (size.height / 8) * 8);
! }
! else if (supported.matches(h263Fmt)) {
// For H.263, we only support some specific sizes.
if (size.width < 128) {
width = 128;
height = 96;
! }
! else if (size.width < 176) {
width = 176;
height = 144;
! }
! else {
width = 352;
height = 288;
}
! }
! else {
// We don't know this particular format. We'll just
// leave it alone then.
***************
*** 279,283 ****
}
-
/**
* Setting the encoding quality to the specified value on the JPEG encoder.
--- 258,261 ----
***************
*** 296,308 ****
if (cs[i] instanceof QualityControl &&
cs[i] instanceof Owned) {
! Object owner = ((Owned)cs[i]).getOwner();
// Check to see if the owner is a Codec.
// Then check for the output format.
if (owner instanceof Codec) {
! Format fmts[] = ((Codec)owner).getSupportedOutputFormats(null);
for (int j = 0; j < fmts.length; j++) {
if (fmts[j].matches(jpegFmt)) {
! qc = (QualityControl)cs[i];
qc.setQuality(val);
System.err.println("- Setting quality to " +
--- 274,286 ----
if (cs[i] instanceof QualityControl &&
cs[i] instanceof Owned) {
! Object owner = ( (Owned) cs[i]).getOwner();
// Check to see if the owner is a Codec.
// Then check for the output format.
if (owner instanceof Codec) {
! Format fmts[] = ( (Codec) owner).getSupportedOutputFormats(null);
for (int j = 0; j < fmts.length; j++) {
if (fmts[j].matches(jpegFmt)) {
! qc = (QualityControl) cs[i];
qc.setQuality(val);
System.err.println("- Setting quality to " +
***************
*** 312,322 ****
}
}
! if (qc != null)
break;
}
}
}
-
/****************************************************************
* Convenience methods to handle processor's state changes.
--- 290,300 ----
}
}
! if (qc != null) {
break;
+ }
}
}
}
/****************************************************************
* Convenience methods to handle processor's state changes.
***************
*** 341,348 ****
if (state == Processor.Configured) {
p.configure();
! } else if (state == Processor.Realized) {
System.out.println("On va realiser le processor");
p.realize();
- System.out.println("Le processor est realized");
}
--- 319,326 ----
if (state == Processor.Configured) {
p.configure();
! }
! else if (state == Processor.Realized) {
System.out.println("On va realiser le processor");
p.realize();
}
***************
*** 354,358 ****
try {
getStateLock().wait();
! } catch (InterruptedException ie) {
return false;
}
--- 332,337 ----
try {
getStateLock().wait();
! }
! catch (InterruptedException ie) {
return false;
}
***************
*** 360,367 ****
}
! if (failed)
return false;
! else
return true;
}
--- 339,348 ----
}
! if (failed) {
return false;
! }
! else {
return true;
+ }
}
***************
*** 370,374 ****
****************************************************************/
! class StateListener implements ControllerListener {
public void controllerUpdate(ControllerEvent ce) {
--- 351,356 ----
****************************************************************/
! class StateListener
! implements ControllerListener {
public void controllerUpdate(ControllerEvent ce) {
***************
*** 376,384 ****
// If there was an error during configure or
// realize, the processor will be closed
! if (ce instanceof ControllerClosedEvent)
setFailed();
// All controller events, send a notification
// to the waiting thread in waitForState method.
if (ce instanceof ControllerEvent) {
synchronized (getStateLock()) {
--- 358,367 ----
// If there was an error during configure or
// realize, the processor will be closed
! if (ce instanceof ControllerClosedEvent) {
setFailed();
// All controller events, send a notification
// to the waiting thread in waitForState method.
+ }
if (ce instanceof ControllerEvent) {
synchronized (getStateLock()) {
***************
*** 390,395 ****
synchronized (endOfMediaSent) {
System.out.println("Evenement DataStarved traite");
! if (!endOfMediaSent.booleanValue())
endOfMediaSent = Boolean.valueOf(true);
try {
Thread.sleep(4000);
--- 373,379 ----
synchronized (endOfMediaSent) {
System.out.println("Evenement DataStarved traite");
! if (!endOfMediaSent.booleanValue()) {
endOfMediaSent = Boolean.valueOf(true);
+ }
try {
Thread.sleep(4000);
|