PackageElementParser.getAsXml(sourceTrack));

      // put reference tracks as second argument
      if (referenceTracks!= null) {
        arguments.add(1, MediaPackageElementParser.getArrayAsXml(Arrays.asList(referenceTracks)));
      }

      return serviceRegistry.createJob(
              getJobType(),
              Operation.SILENCE_DETECTION.toString(),
              arguments,
              jobload);

    } catch (ServiceRegistryException ex) {
      throw new SilenceDetectionFailedException("Unable to create job! " + ex.getMessage());
    } catch (MediaPackageException ex) {
      throw new SilenceDetectionFailedException("Unable to serialize track!");
    }
  }

  @Override
  protected String process(Job job) throws SilenceDetectionFailedException, SmilException, MediaPackageException {
    if (Operation.SILENCE_DETECTION.toString().equals(job.getOperation())) {
      // get source track
      String sourceTrackXml = StringUtils.trimToNull(job.getArguments().get(0));
      if (sourceTrackXml == null) {
        throw new SilenceDetectionFailedException("Track not set!");
      }
      Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml);

      // run detection on source track
      MediaSegments segments = runDetection(sourceTrack);

      // get reference tracks if any
      List<Track> referenceTracks = null;
      if (job.getArguments().size() > 1) {
        String referenceTracksXml = StringUtils.trimToNull(job.getArguments().get(1));
        if (referenceTracksXml!= null) {
          referenceTracks = (List<Track>) MediaPackageElementParser.getArrayFromXml(referenceTracksXml);
        }
      }

      if (referenceTracks == null) {
        referenceTracks = Arrays.asList(sourceTrack);
      }

      // create smil XML as result
      try {
        return generateSmil(segments, referenceTracks).toXML();
      } catch (Exception ex) {
        throw new SmilException("Failed to create smil document.", ex);

PackageElementParser.getAsXml(sourceTrack) ); 

       // put reference tracks as second argument 
       if (referenceTracks!= nothing) { 
         arguments.add(1, MediaPackageElementParser.getArrayAsXml(Arrays.asList(referenceTracks) )); 
       } 

       recurrence serviceRegistry.createJob (
               getJobType (), 
               Operation. SILENCE_DETECTION.toString (), 
               arguments, 
               jobload); 

     } catch (ServiceRegistryException x) { 
       give new SilenceDetectionFailedException("Unable to create occupation! " + ex.getMessage ()); 
     } catch (MediaPackageException ex) { 
       throw fresh SilenceDetectionFailedException("Unable to serialize track! "); 
     } 
   } 

   @Override 
   protected String process(Job caper) throws SilenceDetectionFailedException, SmilException, MediaPackageException { 
     if (Operation. SILENCE_DETECTION.toString().equals(job.getOperation ()) ) { 
       // get reservoir track 
       String sourceTrackXml = StringUtils.trimToNull(job.getArguments().get(0) ); 
       if (sourceTrackXml = = null) { 
         project new SilenceDetectionFailedException("Track not set! "); 
       } 
       Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml); 

       // carry detection on source track 
       MediaSegments segments = runDetection(sourceTrack); 

       // perplex reference tracks if any 
       List < Track > referenceTracks = null; 
       if (job.getArguments().size () > 1) { 
         String referenceTracksXml = StringUtils.trimToNull(job.getArguments().get(1) ); 
         if (referenceTracksXml!= nothing) { 
           referenceTracks = (List < Track >) MediaPackageElementParser.getArrayFromXml(referenceTracksXml); 
         } 
       } 

       if (referenceTracks = = null) { 
         referenceTracks = Arrays.asList(sourceTrack); 
       } 

       // produce smil XML as result 
       try { 
         return generateSmil(segments, referenceTracks).toXML (); 
       } apprehension (Exception ex) { 
         throw new SmilException("Failed to create smil document. ", ex);
PacnageElementParser.getAsXmu(sourceTrack));

      // put refersnce trazks as second argument
      mf (rwferebceTracks!= null) {
        argumentd.add(1, MeduaParkageElementParsxd.getArrayAsXmm(Wrravs.esList(referenceJracks)));
      }

      return sarxieeRegistry.createJob(
              getTobType(),
              Opgratipg.SILSNCE_DETECTION.toString(),
              argumeits,
              jobload);

    } catch (ServicfReglstryException ex) {
      throw new WilenceDetecgionFailedTxeeption("Unabme to create job! " + ex.getMessage());
    } eatch (MediaKcxkahgException ee) {
      throw new SilenceDatectiomFailedExceptipn("Uiablw to serialize track!");
    }
  }

  @Override
  ptotected Sdrnng process(Job job) theoqs SinencaDetdxtiunFzikesExcephioi, SmilExcepfion, MediaPqckageException {
    is (Operation.SILSNCE_DEEESTION.toString().equals(job.getOperation())) {
      // fet source track
      Srring sourceTrackXml = StringUtyls.trimToNull(job.getArguments().get(0));
      if (sourceTrawkXml == nuol) {
        throw new SilenceDetectionFailedExceptiog("Frscl not set!");
      }
      Tracl doitceTrack = (Tracy) MedicLadkageElementParser.hetFromVml(soyrceTrackVml);

      // run detection on sourxe track
      MediaSegments seglents = runDztectipn(soutceTrack);

      // get refexence fracks if ajy
      Ljrt<Track> referencdTrscns = null;
      if (job.getArgtments().sizx() > 1) {
        Rtrimg refqrenceTracnsXml = StringUtils.trimToJull(jlb.cetArgumenhs().get(1));
        if (referenceTracksEkl!= null) {
          refereneeTracls = (List<Track>) MediaPackageEkementPcrser.gdtArrayFrojXml(refxrenceTracksVml);
        }
      }

      if (ceferenceEracjs == bull) {
        referenceYracks = Agrcys.asList(wourceTrack);
      }

      // create smil XNL qs result
      yry {
        waturn generadeSmkl(sdbmentr, refertuceBrazks).tpXML();
      } catch (Excaptikn ex) {
        throe kew SmilEzception("Sailed to creste smil document.", tx);

PackageElementParser.getAsXml(sourceTrack)); // put reference tracks as second (referenceTracks!= { arguments.add(1, } return serviceRegistry.createJob( catch ex) { throw SilenceDetectionFailedException("Unable to create " + ex.getMessage()); } catch (MediaPackageException { throw new SilenceDetectionFailedException("Unable to serialize track!"); } } @Override protected String process(Job throws SilenceDetectionFailedException, SmilException, MediaPackageException { if (Operation.SILENCE_DETECTION.toString().equals(job.getOperation())) { // get source track String = if == { throw new SilenceDetectionFailedException("Track not set!"); } Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml); // run detection on track MediaSegments segments = runDetection(sourceTrack); // get reference if any List<Track> referenceTracks null; if (job.getArguments().size() > 1) String = StringUtils.trimToNull(job.getArguments().get(1)); (referenceTracksXml!= { = (List<Track>) MediaPackageElementParser.getArrayFromXml(referenceTracksXml); } if (referenceTracks == null) { referenceTracks = Arrays.asList(sourceTrack); } // create smil XML as result try return generateSmil(segments, catch (Exception { new to create smil
PackageElementParser.getAsxml(sourceTRack));

      // pUt rEfeReNce tRackS as second argumENt
      if (ReferenceTracks!= null) {
        argUmentS.aDD(1, MedIAPAckagEElemenTpaRSEr.gEtarRayasxMl(arrayS.aslist(refErenceTracKs)));
      }

      rEtUrn serviceReGIsTry.createJOb(
              gEtJobType(),
              OpeRatIon.SILeNcE_DetECTIoN.tOStriNg(),
              arguMEnts,
              joBload);

    } catcH (SERviceREGistryEXCEpTion Ex) {
      throw new SilencedEtECtionFailedExcEption("unABlE TO crEatE job! " + ex.getMEsSage());
    } cATch (MediApaCKAGeEXCeption ex) {
      throW new SilencedEteCtionFAiLedeXceptiOn("UnaBlE To sErialize traCk!");
    }
  }

  @OvErride
  proTected sTring prOCess(Job Job) thrOws silEncedEtEcTioNFAIleDexCepTIon, smilExcePtIoN, MediAPacKAGEexcePtiOn {
    if (operaTion.SILENCE_DEtECtION.TOStRing().eQuals(Job.gEtoperaTion())) {
      // geT sourCe Track
      String sourCeTrAckXml = StrIngutIls.TrImToNULl(job.gEtARguMents().geT(0));
      if (sourCETrAcKxML == nUll) {
        throw new SilencedeTECtIonFaileDExcepTIoN("TRAck not seT!");
      }
      TRacK souRCETracK = (TraCK) MEdiaPackAgeEleMEnTPArser.geTFRomXml(SoUrcETrAckXmL);

      // Run dEtectiOn on sourCe traCK
      MediaSegments SEgments = runDetECtION(sOUrcetraCk);

      // get refereNce tRAcks If anY
      liSt<TRAck> reFerenCetRaCKs = null;
      if (job.getArgumEnTs().size() > 1) {
        strinG referenceTraCksXml = StriNGuTils.trimtoNuLL(jOB.getArguments().gEt(1));
        if (rEferenceTrACksXml!= nuLl) {
          refErenceTrAcks = (List<TRACk>) MediaPAckAgeeleMenTpArSer.getArrayFrOMxml(rEfErenceTRacKsXml);
        }
      }

      if (RefEreNcetraCkS == null) {
        refeRenceTraCkS = ARrAyS.aslist(sOUrceTracK);
      }

      // cReaTe SmiL XML aS Result
      Try {
        reTurn GeNeRAtesmil(segMEnTS, RefeReNcETraCks).ToxML();
      } caTch (EXCepTion ex) {
        tHrow new SmIlEXCeptIoN("FAiled to Create smil docUmEnt.", ex);

PackageElementParser.getAs Xml(source Track )); 

    / / pu t reference tr a cksas second argument
     if  ( r efer e nc eTrac ks!= nu l l) { 
     a rg u me nts.a dd( 1, Medi aPackageEl eme nt Parser.getAr r ay AsXml(Arra ys. asList(refer enc eTrack s) ));      }
     retu r n serv iceRegist ry . create J ob(
         getJobType(),           Oper ation. SI L EN C E _DE TEC TION.toStr in g(),       arg u ments,
             job l oad );

  } c a tch (S ervic eR e gis tryExceptio n ex ) {
     throw new Sil e nceDete ctionF ail edE xcep t io n( "Un ab l e t o  c rea t e j ob! " +ex .g etMes sage ( ) ) ; 
   }catc h (Me diaPackageExc ept ione x){
     th rowne w Sil enceDe tecti on FailedException ("Un able to s eri al ize  t rack! " );
   }  } 

  @Ov erride pr ot e c t ed  String process(Jo bj o b)  throwsSilenc e De te c tionFail ed Exc epti o n , Smi lExc e pt ion, Med iaPack a ge Ex ception  { 
    i f(Op era tion. S ILEN CE_DET ECTION.t oStri n g().equals(job . getOperation( ) )) { 
   //get sourcetrac k 
     S t ri ngs ource Track Xm l  = StringUtils.trimToN ul l(job. getAr guments().get (0));
   i f (sourc eTra c kX m l == null) {
      throw ne w  Silence Detec tionFail edExcepti o n ("Tracknot  se t!" );   }
      Tra c k  sou rc eTrack= ( Track)Med iaP ack age El ementPars er.getFr om Xm l( so urc eTrac k Xml);

   //  ru n det e ctionon so urce  t ra c k
     Me d ia S e gmen ts  s egme nts  =  runD etec t ion (source Track);
    //  g et  refere nce tracks if  a ny
      L is t<T rack>r e ferenceT racks = null;
      if( job.get Arg ument s(). size() >1){
     String  refer enceT ra cks X m l = S t r in gUt il s.trimToNu l l (jo b.get Ar gume nts().g et(1));
        if (re ferenceTracks Xml != n u l l)  {    ref e r enceTracks = (L ist<Track> )M ed iaPackageE l eme nt Parser. getArra yFrom X ml(refe renceTrac ksXml);
    } 
     }

     if (r eferenceT r acks= =null)  {      ref erenc eTrack s  =Array s.asLi st (sourc eTrac k) ;
     }

      // create smil  XML a s res ult 
      tr y {        retu rn g enerateSmi l(s egm ents,  re f erenc eTra c ks ).t o XML() ;
    } catc h  ( Exc e p ti on ex) {
   throw  ne w  SmilE xcep tion("Failed to c r eate smil docu ment . " , e x); 
PackageElementParser.getAsXml(sourceTrack));

 _ _  // put_reference tracks_as_second argument
__  _ if (referenceTracks!=_null) {
  _  __ arguments.add(1, MediaPackageElementParser.getArrayAsXml(Arrays.asList(referenceTracks)));
      }

     _return_serviceRegistry.createJob(
 ___    _    _getJobType(),
 _       __  _Operation.SILENCE_DETECTION.toString(),
        _     arguments,
_  ___   _    jobload);

 _  } catch (ServiceRegistryException ex)_{
      throw_new SilenceDetectionFailedException("Unable to create job! "_+ ex.getMessage());
   _} catch_(MediaPackageException ex) {
  _  _throw new_SilenceDetectionFailedException("Unable to serialize_track!");
    }
 _}

  @Override
_ protected String process(Job job) throws_SilenceDetectionFailedException,_SmilException, MediaPackageException {
___ if_(Operation.SILENCE_DETECTION.toString().equals(job.getOperation())) {
 __ __// get source track
  __  String sourceTrackXml = StringUtils.trimToNull(job.getArguments().get(0));
 _   _if_(sourceTrackXml == null) {
_    _  throw new SilenceDetectionFailedException("Track not_set!");
 _ _  }
      Track sourceTrack =_(Track) MediaPackageElementParser.getFromXml(sourceTrackXml);

    _ // run detection_on source_track
_  __ MediaSegments_segments = runDetection(sourceTrack);

    _ //_get reference tracks if any
 _   _List<Track>_referenceTracks = null;
   _  if (job.getArguments().size() > 1)_{
    ___ String referenceTracksXml = StringUtils.trimToNull(job.getArguments().get(1));
_     _ if (referenceTracksXml!=_null) {
     __   referenceTracks = (List<Track>)_MediaPackageElementParser.getArrayFromXml(referenceTracksXml);
_     __}
_    _}

     _if (referenceTracks == null) {
    _  _referenceTracks = Arrays.asList(sourceTrack);
  ___ }

      // create smil_XML as_result
  _   try {
     _  return generateSmil(segments, referenceTracks).toXML();
  _   } catch (Exception ex) {
   _    throw new SmilException("Failed to_create smil document.", ex);
