MultipleMediaSource implements IMediaSource { public long getSegmentsDurationInMicroSec() { long totalDuration = 0; for (MediaFile mediaFile : mediaFiles) { totalDuration += mediaFile.getSegmentsDurationInMicroSec(); } return totalDuration; }  @Override CommandQueue getOutputCommandQueue(); @Override void fillCommandQueues(); @Override void close(); @Override void pull(Frame frame); void nextFile(); @Override MediaFormat getMediaFormatByType(MediaFormatType mediaFormatType); boolean isLastFile(); @Override void incrementConnectedPluginsCount(); @Override void start(); List<MediaFile> files(); void add(MediaFile mediaFile); long getMaxCurrentTimeOffset(); @Override int getTrackIdByMediaType(MediaFormatType mediaFormatType); @Override void selectTrack(int trackId); void setTrackMap(int source, int target); @Override void stop(); @Override boolean canConnectFirst(IInputRaw connector); long getSegmentsDurationInMicroSec(); void remove(MediaFile mediaFile); void insertAt(int index, MediaFile mediaFile); @Override Resolution getOutputResolution(); boolean hasTrack(MediaFormatType mediaFormatType); void verify();  }
@Test public void getSegmentsDurationForTwoFiles() throws RuntimeException { MediaSource trackWithAudioDuration100 = create.mediaSource().with( create.audioFormat().withDuration(100).construct()) .construct(); MediaSource trackWithAudioDuration200 = create.mediaSource().with( create.audioFormat().withDuration(200).construct()) .construct(); MultipleMediaSource multipleMediaSource=create.multipleMediaSource() .with(trackWithAudioDuration100) .with(trackWithAudioDuration200) .construct(); assertEquals(300, multipleMediaSource.getSegmentsDurationInMicroSec()); }