public void prepareContext() throws InvalidAudioChannelAssignmentException { new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); prepareSoundfieldGroups(); }
@Override public void prepareContext() { prepareChannelsByOrder(); try { super.prepareContext(); essenceLayoutValid = true; } catch (InvalidAudioChannelAssignmentException e) { logger.warn("Layout form Essence descriptors set in CPL cannot properly defined. {}", e.getLocalizedMessage()); essenceLayoutValid = false; } }
private List<Pair<SequenceUUID, Integer>> getChannelsByLayout(FFmpegAudioChannels[] channelsGroup, SoundfieldGroupInfo soundfieldGroup) { return Stream.of(channelsGroup) .map(soundfieldGroup.getChannelsMap()::get) .collect(Collectors.toList()); }
@Test(expected = InvalidAudioChannelAssignmentException.class) public void checkNoChannelLayout() throws Exception { TemplateParameterContextProvider contextProvider = AudioUtils.createContext(4, new FFmpegAudioChannels[][]{ }); new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); }
public void addChannels(SequenceUUID uuid, FFmpegAudioChannels[] channels) throws InvalidAudioChannelAssignmentException { for (int i = 0; i < channels.length; i++) { FFmpegAudioChannels channel = channels[i]; if (channelsMap.containsKey(channel)) { throw new InvalidAudioChannelAssignmentException("A soundfield group must contain different channels"); } channelsMap.put(channel, ImmutablePair.of(uuid, i + 1)); } }
public void addChannels(SequenceUUID uuid, String channels) throws InvalidAudioChannelAssignmentException { addChannels(uuid, FFmpegAudioChannels.toFFmpegAudioChannels(channels)); }
private AudioMapType getDefaultAudioMap() { AudioMapType audioMap = null; logger.warn("No audiomap.xml specified as a command line argument. A default audiomap.xml will be generated."); try { audioMap = new AudioMapGuesser(contextProvider, audioLayout).guessAudioMap(); } catch (InvalidAudioChannelAssignmentException e) { logger.warn("Could not generate an audiomap based on EssenceDescriptor: " + e.getMessage()); } if (audioMap == null) { logger.debug("Generating default audiomap in a natural order..."); audioMap = generateDefaultXml(); logger.info("Generated default audiomap in a natural order: OK"); } return audioMap; }
@Test public void checkAllResourcesEqualChannelLayout() throws Exception { TemplateParameterContextProvider contextProvider = AudioUtils.createContext(2, 2, 2, new FFmpegAudioChannels[][]{ {FL, FR}, {FL, FR}, {FL, FR}, {FL, FR}, {FL, FR, FC, LFE, SL, SR}, {FL, FR, FC, LFE, SL, SR}, {FL, FR, FC, LFE, SL, SR}, {FL, FR, FC, LFE, SL, SR} }); new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); }
private boolean isGroupUsed(SoundfieldGroupInfo soundfieldGroup) { return soundfieldGroup.getChannelsMap().values().stream() .noneMatch(this::isChannelUsed); }
private AudioMapType processR482A() throws InvalidAudioChannelAssignmentException { AudioMapType audioMap = new AudioMapType(); List<SoundfieldGroupInfo> foundStereo = findInputForChannelGroup(STEREO_LAYOUT); // use the first found stereo pair if (foundStereo.isEmpty()) { throw new InvalidAudioChannelAssignmentException( String.format("Expected at least one stereo for %s", EBU_R_48_2_A.value())); } addStereo(audioMap, 1, foundStereo.get(0)); addStereoSilence(audioMap, 3); return audioMap; }
@Test public void checkNoAudio() throws Exception { TemplateParameterContextProvider contextProvider = AudioUtils.createContext(0, new FFmpegAudioChannels[][]{ }); new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); }
protected List<SoundfieldGroupInfo> findInputForChannelGroup(FFmpegAudioChannels[] channelsGroup) { List<SoundfieldGroupInfo> result = new ArrayList<>(); for (SoundfieldGroupInfo soundfieldGroupInfo : inputSoundfieldGroups.values()) { Set<FFmpegAudioChannels> inputChannels = soundfieldGroupInfo.getChannelsMap().keySet(); Set<FFmpegAudioChannels> requiredChannels = new HashSet<>(Arrays.asList(channelsGroup)); if (!inputChannels.equals(requiredChannels)) { continue; } result.add(soundfieldGroupInfo); } return result; }
private AudioMapType processR1234B4C() throws InvalidAudioChannelAssignmentException { AudioMapType audioMap = new AudioMapType(); List<SoundfieldGroupInfo> foundStereo = findInputForChannelGroup(STEREO_LAYOUT); // we expect one or two stereo if (foundStereo.isEmpty() || foundStereo.size() > 2) { throw new InvalidAudioChannelAssignmentException( String.format("Expected one or two stereo for %s and %s", EBU_R_123_4_B.value(), EBU_R_123_4_C.value())); } addStereo(audioMap, 1, foundStereo.get(0)); // final stereo if (foundStereo.size() == 2) { addStereo(audioMap, 3, foundStereo.get(1)); // M&E stereo } else { addStereoSilence(audioMap, 3); } return audioMap; }
@Test(expected = InvalidAudioChannelAssignmentException.class) public void checkChannelLayoutNotMatchChannelNum() throws Exception { TemplateParameterContextProvider contextProvider = AudioUtils.createContext(4, 1, 1, new FFmpegAudioChannels[][]{ {FL, FR}, {FL, FR}, {FL, FR}, {FL, FR}, }, new String[]{}, new int[]{1, 1, 1, 1}, new String[]{} ); new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); }
public static void add51(AudioMapType audioMapType, int num, SoundfieldGroupInfo fiveOne) { for (FFmpegAudioChannels channel : SURROUND_5_1_LAYOUT) { audioMapType.getEBUTrack().add( createEbuTrack(num, fiveOne.getChannelsMap().get(channel))); num++; } }
@Test(expected = InvalidAudioChannelAssignmentException.class) public void checkAllResourcesSwappedChannelLayout() throws Exception { TemplateParameterContextProvider contextProvider = AudioUtils.createContext(2, 2, 2, new FFmpegAudioChannels[][]{ {FL, FR}, {FR, FL}, {FL, FR}, {FL, FR}, {FL, FR, FC, LFE, SL, SR}, {SL, SR, FC, LFE, FL, FR}, {LFE, SL, SR, FL, FR, FC,}, {FC, FR, LFE, SL, SR} }); new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); }
public static void addStereo(AudioMapType audioMapType, int num, SoundfieldGroupInfo stereo) { for (FFmpegAudioChannels channel : STEREO_LAYOUT) { audioMapType.getEBUTrack().add( createEbuTrack(num, stereo.getChannelsMap().get(channel))); num++; } }
@Test(expected = InvalidAudioChannelAssignmentException.class) public void check_noChannelLayout_forAll() throws Exception { TemplateParameterContextProvider contextProvider = AudioUtils.createContext(4, new FFmpegAudioChannels[][]{ {FL, FR, FC, LFE, SL, SR} }); new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); }
protected String getLanguage(SoundfieldGroupInfo info) { String lang = null; for (ImmutablePair<SequenceUUID, Integer> seqInfos : info.getChannelsMap().values()) { SequenceTemplateParameterContext seqContext = contextProvider.getSequenceContext(); ContextInfo contextInfo = new ContextInfoBuilder() .setSequenceType(SequenceType.AUDIO) .setSequenceUuid(seqInfos.getLeft()) .build(); if (!seqContext.hasSequenceParameter(SequenceContextParameters.LANGUAGE, contextInfo)) { return null; } String nextLang = seqContext.getParameterValue(SequenceContextParameters.LANGUAGE, contextInfo); // all sequences from a soundfield group must have the same language! if (lang != null && !lang.equals(nextLang)) { return null; } lang = nextLang; } return lang; }
@Test(expected = InvalidAudioChannelAssignmentException.class) public void checkAllResourcesDifferentChannelLayout() throws Exception { TemplateParameterContextProvider contextProvider = AudioUtils.createContext(2, 2, 2, new FFmpegAudioChannels[][]{ {FL, FR}, {FL}, {FL, FR}, {FL, FR}, {FL, FR, FC, LFE, SL, SR}, {SL, SR, FC, LFE, FL, FR}, {LFE, SL, SR, FL, FR, FC,}, {FC} }); new AudioLayoutChecker(contextProvider).checkCorrectChannelLayout(); } }