Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Bin newPlayBin(RSBin bin, String fileName, long fadeoutStartTime, double gain){
- String name = bin.getName()+(playBinCount++);
- Bin playBin = null;
- try{
- logger.debug("InitPreview: Initializing Preview Bin.");
- //Pipeline playPipe = new Pipeline(name+PIPELINE);
- playBin = new Bin(name+BIN);
- final Element source = ElementFactory.make("filesrc", name+SOURCE);
- final DecodeBin decodeBin = new DecodeBin (name+"Decode");
- final Element audioConvert = ElementFactory.make("audioconvert", name+AUDIOCONVERT);
- decodeBin.connect(new DecodeBin.NEW_DECODED_PAD(){
- public void newDecodedPad(Element element, Pad pad, boolean last){
- decodeBin.link(audioConvert);
- }
- });
- Element resample = ElementFactory.make(resampler, name+RESAMPLE);
- //Element rgVolume = ElementFactory.make("rgvolume", name+"RGVolume");
- Element volume = ElementFactory.make("volume", name+VOLUME);
- Double binVolume = bin.getVolume() * dBToLinear(gain);
- volume.set("volume", Double.toString(binVolume));
- logger.debug("SETTING VOLUME TO: "+binVolume);
- String mixer = null, deviceName = null;
- String resourceType = null;
- if (bin == RSBin.PLAYOUT)
- resourceType = AudioService.PLAYOUT;
- else
- resourceType = AudioService.PREVIEW;
- ResourceConfig resourceConfig = getResourceConfig(RSController.AUDIO_SERVICE, resourceType);
- mixer = resourceConfig.resourceMixer();
- deviceName = resourceConfig.resourceDeviceName();
- Element playSink = getAudioSink(mixer, deviceName, name);
- logger.info("NewPlayBin: Using sink mixer: "+mixer+" deviceName: "+deviceName + " type: "+resourceType);
- playBin.addMany(source, decodeBin, audioConvert, resample, /*rgVolume,*/ volume, playSink);
- playBin.linkMany(source, decodeBin);
- playBin.linkMany(audioConvert, resample, /*rgVolume,*/ volume, playSink);
- playBin.setState(State.NULL);
- pipe.add(playBin);
- //playPipe.add(playBin);
- if (playBinCount == 1){
- Bus bus = playBin.getBus();
- //Bus bus = playPipe.getBus();
- Bus.STATE_CHANGED stateChanged = new Bus.STATE_CHANGED(){
- public void stateChanged(GstObject source, State old, State cur, State pending){
- stateHandler.stateChanged(source, old, cur, pending);
- }
- };
- bus.connect(stateChanged);
- Bus.EOS eos = new Bus.EOS(){
- public void endOfStream(GstObject source){
- logger.info("EndOfStream: EOS received from: "+source);
- handleEOS(source);
- }
- };
- bus.connect(eos);
- Bus.ERROR error = new Bus.ERROR(){
- public void errorMessage(GstObject source, int code, String message){
- handleError(source, message);
- }
- };
- bus.connect(error);
- Bus.TAG tag = new Bus.TAG(){
- public void tagsFound(GstObject source, TagList tagList){
- handleTags(source, tagList);
- }
- };
- bus.connect(tag);
- }
- bin.setInit();
- rsBins.put(playBin, bin);
- PlayBinInfo binInfo = new PlayBinInfo(bin, playBin, fadeoutStartTime);
- playBinInfos.put(playBin, binInfo);
- return playBin;
- /*
- rsBins.put(playPipe, bin);
- PlayBinInfo binInfo = new PlayBinInfo(bin, playPipe, fadeoutStartTime);
- playBinInfos.put(playPipe, binInfo);
- return playPipe;
- */
- } catch (Exception e) {
- logger.error("InitPreview: Could not initialize.", e);
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement