Should be called by subclass when it is ready
        to acquire the media transport file descriptor
324825
def _acquire_media_transport(self, path, access_type):
        
        transport = BTMediaTransport(path=path)
        (fd, read_mtu, write_mtu) = transport.acquire(access_type)
        self.fd = fd.take()   # We must do the clean-up later
        self.write_mtu = write_mtu
        self.read_mtu = read_mtu
        self.access_type = access_type
        self.path = path
        self._install_transport_ready()
839396
function (successCallback, errorCallback, args) {
		winble.logger.logApiEntry("writeDescriptor");
		var deviceHandle = args[0] ? args[0] : "";
		var descHandle = args[1] ? args[1] : "";
		var dataBuffer = args[2] ? args[2] : "";
		winble.deviceManager.writeDescriptor(successCallback, errorCallback, deviceHandle, descHandle, dataBuffer);
		winble.logger.logApiExit("writeDescriptor");
	}
310038
public void init(SecorConfig config, OffsetTracker offsetTracker, FileRegistry fileRegistry,
                     UploadManager uploadManager, MessageReader messageReader,
                     ZookeeperConnector zookeeperConnector, MetricCollector metricCollector,
                     DeterministicUploadPolicyTracker deterministicUploadPolicyTracker) {
        mConfig = config;
        mOffsetTracker = offsetTracker;
        mFileRegistry = fileRegistry;
        mUploadManager = uploadManager;
        mMessageReader = messageReader;
        mZookeeperConnector = zookeeperConnector;
        mTopicFilter = mConfig.getKafkaTopicUploadAtMinuteMarkFilter();
        mMetricCollector = metricCollector;
        mDeterministicUploadPolicyTracker = deterministicUploadPolicyTracker;
        if (mConfig.getOffsetsStorage().equals(SecorConstants.KAFKA_OFFSETS_STORAGE_KAFKA)) {
            isOffsetsStorageKafka = true;
        }
    }
339472
private Resource getMediaInlineResource(MediaRequest mediaRequest) {
    Resource resource = mediaRequest.getResource();
    if (resource == null) {
      return null;
    }

    // check if resource itself is a nt:file node
    if (JcrBinary.isNtFileOrResource(resource)) {
      return resource;
    }

    // check if child node exists which is a nt:file node
    String refProperty = StringUtils.defaultString(mediaRequest.getRefProperty(), mediaHandlerConfig.getMediaInlineNodeName());
    Resource mediaInlineResource = resource.getChild(refProperty);
    if (JcrBinary.isNtFileOrResource(mediaInlineResource)) {
      return mediaInlineResource;
    }

    // not found
    return null;
  }
1117135
public void init(RecordOwner screen, ClassInfoModel recDetail)
    {
        m_recDetail = null;
        m_recDetail = recDetail;
        super.init(screen);
    }
574978
def _property_change_event_handler(self, signal, transport, *args):
        
        current_state = self.source.State
        if (self.state == 'connected' and current_state == 'playing'):
            self._acquire_media_transport(transport, 'r')
        elif (self.state == 'playing' and current_state == 'connected'):
            self._release_media_transport(transport, 'r')
        self.state = current_state
125339
function initRouter(mediatorService, storageConfiguration) {
  var router = express.Router();
  var storageEngine = StorageEngine(storageConfiguration);
  router.route('/all').get(function(req, res, next) {
    mediatorService.listFilesMetadata().then(function(fileList) {
      res.json(fileList);
    }).catch(function(err) {
      console.log("Cannot retrieve metadata", err);
      next(err);
    });
  });
  
  router.route('/owner/:owner').get(function(req, res, next) {
    var owner = req.params.owner;
    mediatorService.listFilesMetadata(owner).then(function(fileList) {
      res.json(fileList);
    }).catch(function(err) {
      console.log("Cannot retrieve metadata", err);
      next(err);
    });
  });
  
  router.route('/owner/:owner/upload/base64/:filename').post(function(req, res, next) {
    var uid = uuid.create().toString();
    var fileMeta = {
      owner: req.params.owner,
      name: req.params.filename,
      namespace: req.params.namespace,
      uid: uid,
      id: uid
    };
    var stream = fileService.parseBase64Stream(req);
    fileService.writeStreamToFile(fileMeta, stream).then(function() {
      var location = fileService.filePath(fileMeta.uid);
      return storageEngine.writeFile(fileMeta.namespace, fileMeta.uid, location);
    }).then(function() {
      return mediatorService.createFileMetadata(fileMeta);
    }).then(function() {
      res.json(fileMeta);
    }).catch(function(err) {
      console.log(err);
      next(err);
    });
  });
  
  var binaryUploadInitMiddleware = function(req, res, next) {
    req.fileMeta = {};
    req.fileMeta.id = uuid.create().toString();
    req.fileMeta.uid = req.fileMeta.id;
    next();
  };
  
  router.route('/upload/binary').post(binaryUploadInitMiddleware, fileService.mutlerMiddleware(),
    function(req, res, next) {
      var fileMeta = req.fileMeta;
      req.fileMeta.name = req.body.fileName;
      req.fileMeta.namespace = req.body.namespace;
      req.fileMeta.owner = req.body.ownerId;
      req.fileMeta.mimetype = req.file.mimetype;
      var location = fileService.filePath(fileMeta.uid);
      storageEngine.writeFile(fileMeta.namespace, fileMeta.uid, location).then(function() {
        return mediatorService.createFileMetadata(fileMeta);
      }).then(function() {
        res.json(fileMeta);
      }).catch(function(err) {
        console.log(err);
        next(err);
      });
    });
  
  router.route('/get/:filename').get(function(req, res) {
    var fileName = req.params.filename;
    var namespace = req.params.namespace;
    storageEngine.streamFile(namespace, fileName).then(function(buffer) {
      if (buffer) {
        buffer.pipe(res);
      } else {
        res.sendFile(fileService.filePath(fileName));
      }
    });
  });
  return router;
}
929855
private void triggerTransportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException, InterruptedException {
        List<JingleListener> listeners = getListenersList();
        for (JingleListener li : listeners) {
            if (li instanceof JingleTransportListener) {
                JingleTransportListener mli = (JingleTransportListener) li;
                LOGGER.fine("triggerTransportEstablished " + local.getLocalIp() + ":" + local.getPort() + " <-> "
                        + remote.getIp() + ":" + remote.getPort());
                mli.transportEstablished(local, remote);
            }
        }
    }
267137
function WhammyRecorder(mediaStream) {
    // void start(optional long timeSlice)
    // timestamp to fire "ondataavailable"
    this.start = function(timeSlice) {
        timeSlice = timeSlice || 1000;

        mediaRecorder = new WhammyRecorderHelper(mediaStream, this);

        for (var prop in this) {
            if (typeof this[prop] !== 'function') {
                mediaRecorder[prop] = this[prop];
            }
        }

        mediaRecorder.record();

        timeout = setInterval(function() {
            mediaRecorder.requestData();
        }, timeSlice);
    };

    this.stop = function() {
        if (mediaRecorder) {
            mediaRecorder.stop();
            clearTimeout(timeout);
            this.onstop();
        }
    };

    this.onstop = function() {};

    this.clearOldRecordedFrames = function() {
        if (mediaRecorder) {
            mediaRecorder.clearOldRecordedFrames();
        }
    };

    this.pause = function() {
        if (!mediaRecorder) {
            return;
        }

        mediaRecorder.pause();
    };

    this.resume = function() {
        if (!mediaRecorder) {
            return;
        }

        mediaRecorder.resume();
    };

    this.ondataavailable = function() {};

    // Reference to "WhammyRecorder" object
    var mediaRecorder;
    var timeout;
}
1193733
@SuppressWarnings({ "null", "unused" })
  @NotNull
  Media processRequest(@NotNull final MediaRequest mediaRequest) {

    // detect media source
    MediaSource mediaSource = null;
    List<Class<? extends MediaSource>> mediaSources = mediaHandlerConfig.getSources();
    if (mediaSources == null || mediaSources.isEmpty()) {
      throw new RuntimeException("No media sources defined.");
    }
    MediaSource firstMediaSource = null;
    for (Class<? extends MediaSource> candidateMediaSourceClass : mediaSources) {
      MediaSource candidateMediaSource = AdaptTo.notNull(adaptable, candidateMediaSourceClass);
      if (candidateMediaSource.accepts(mediaRequest)) {
        mediaSource = candidateMediaSource;
        break;
      }
      else if (firstMediaSource == null) {
        firstMediaSource = candidateMediaSource;
      }
    }
    // if no media source was detected use first media resource defined
    if (mediaSource == null) {
      mediaSource = firstMediaSource;
    }
    Media media = new Media(mediaSource, mediaRequest);

    // resolve media format names to media formats
    MediaFormatResolver mediaFormatResolver = new MediaFormatResolver(mediaFormatHandler);
    if (!mediaFormatResolver.resolve(mediaRequest.getMediaArgs())) {
      media.setMediaInvalidReason(MediaInvalidReason.INVALID_MEDIA_FORMAT);
      return media;
    }

    // if only downloads are accepted prepare media format filter set which only contains download media formats
    if (!resolveDownloadMediaFormats(mediaRequest.getMediaArgs())) {
      media.setMediaInvalidReason(MediaInvalidReason.INVALID_MEDIA_FORMAT);
      return media;
    }

    // apply defaults to media args
    if (mediaRequest.getMediaArgs().isIncludeAssetWebRenditions() == null) {
      mediaRequest.getMediaArgs().includeAssetWebRenditions(mediaHandlerConfig.includeAssetWebRenditionsByDefault());
    }

    // preprocess media request before resolving
    List<Class<? extends MediaProcessor>> mediaPreProcessors = mediaHandlerConfig.getPreProcessors();
    if (mediaPreProcessors != null) {
      for (Class<? extends MediaProcessor> processorClass : mediaPreProcessors) {
        MediaProcessor processor = AdaptTo.notNull(adaptable, processorClass);
        media = processor.process(media);
        if (media == null) {
          throw new RuntimeException("MediaPreProcessor '" + processor + "' returned null, request: " + mediaRequest);
        }
      }
    }

    // resolve media request
    media = mediaSource.resolveMedia(media);
    if (media == null) {
      throw new RuntimeException("MediaType '" + mediaSource + "' returned null, request: " + mediaRequest);
    }

    // generate markup (if markup builder is available) - first accepting wins
    List<Class<? extends MediaMarkupBuilder>> mediaMarkupBuilders = mediaHandlerConfig.getMarkupBuilders();
    if (mediaMarkupBuilders != null) {
      for (Class<? extends MediaMarkupBuilder> mediaMarkupBuilderClass : mediaMarkupBuilders) {
        MediaMarkupBuilder mediaMarkupBuilder = AdaptTo.notNull(adaptable, mediaMarkupBuilderClass);
        if (mediaMarkupBuilder.accepts(media)) {
          media.setElement(mediaMarkupBuilder.build(media));
          break;
        }
      }
    }

    // postprocess media request after resolving
    List<Class<? extends MediaProcessor>> mediaPostProcessors = mediaHandlerConfig.getPostProcessors();
    if (mediaPostProcessors != null) {
      for (Class<? extends MediaProcessor> processorClass : mediaPostProcessors) {
        MediaProcessor processor = AdaptTo.notNull(adaptable, processorClass);
        media = processor.process(media);
        if (media == null) {
          throw new RuntimeException("MediaPostProcessor '" + processor + "' returned null, request: " + mediaRequest);
        }
      }
    }

    return media;
  }
313016
private void triggerContentEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc) throws NotConnectedException, InterruptedException {

        // Let the session know that we've established a content/media segment.
        JingleSession session = getSession();
        if (session != null) {
            List<JingleListener> listeners = session.getListenersList();
            for (JingleListener li : listeners) {
                if (li instanceof JingleSessionListener) {
                    JingleSessionListener sli = (JingleSessionListener) li;
                    sli.sessionEstablished(pt, rc, lc, session);
                }
            }
        }

        // Create a media session for each media manager in the session.
        if (mediaNeg.getMediaManager() != null) {
            rc.removeCandidateEcho();
            lc.removeCandidateEcho();

            jingleMediaSession = getMediaNegotiator().getMediaManager().createMediaSession(pt, rc, lc, session);
            jingleMediaSession.addMediaReceivedListener(session);
            if (jingleMediaSession != null) {

                jingleMediaSession.startTransmit();
                jingleMediaSession.startReceive();

                for (TransportCandidate candidate : getTransportNegotiator().getOfferedCandidates())
                    candidate.removeCandidateEcho();
            }
            JingleMediaManager mediaManager = getMediaNegotiator().getMediaManager();
            getSession().addJingleMediaSession(mediaManager.getName(), jingleMediaSession);
        }

    }
1337484
@Override
    	protected void doSuccessResponse(SipServletResponse resp)
			throws ServletException, IOException {
		if (resp.getStatus() == SipServletResponse.SC_OK) {
			String audioFilePath = (String)getServletContext().getAttribute("audioFilePath");
			logger.info("audio file path is " + audioFilePath);
			try {
				MsPeer peer = MsPeerFactory.getPeer("org.mobicents.mscontrol.impl.MsPeerImpl");
				MsProvider provider = peer.getProvider();
				MsSession session = provider.createSession();
				MsConnection connection = session.createNetworkConnection(PR_JNDI_NAME);
				MediaConnectionListener listener = new MediaConnectionListener();
				listener.setResponse(resp);
				listener.setAudioFilePath(audioFilePath);
				connection.addConnectionListener(listener);
				Object sdpObj = resp.getContent();
				byte[] sdpBytes = (byte[]) sdpObj;
				String sdp = new String(sdpBytes); 
				connection.modify("$", sdp);
			} catch (ClassNotFoundException e) {
				logger.error("class not found ", e);
			}			
		}
	}
1183762
protected long getFileDescriptor() throws AsyncException {
        FieldReturn fRet = AccessController.doPrivileged(new PrivFieldCheck(channel));
        if (fRet.e != null) {
            throw fRet.e;
        }
        return fRet.val;
    }
921878
def acquire(self):
        
        # handle thread lock
        if Handler:
            # under some tests Handler ends up being null due to instantiation
            # order
            Handler.acquire(self)

        # Issue a file lock.  (This is inefficient for multiple active threads
        # within a single process. But if you're worried about high-performance,
        # you probably aren't using this log handler.)
        if self.stream_lock:
            # If stream_lock=None, then assume close() was called or something
            # else weird and ignore all file-level locks.
            if self.stream_lock.closed:
                # Daemonization can close all open file descriptors, see
                # https://bugzilla.redhat.com/show_bug.cgi?id=952929
                # Try opening the lock file again.  Should we warn() here?!?
                try:
                    self._open_lockfile()
                except Exception:
                    self.handleError(NullLogRecord())
                    # Don't try to open the stream lock again
                    self.stream_lock = None
                    return
            lock(self.stream_lock, LOCK_EX)
924412
public void negotiateFormats(MediaDescriptionField media) {
		// Clean currently offered formats
		this.offeredFormats.clean();
		
		// Map payload types to RTP Format
        for (String payloadType : media.getPayloadTypes()) {
        	RTPFormat format;
        	try {
				int payloadTypeInt = Integer.parseInt(payloadType);

				if(payloadTypeInt < AVProfile.DYNAMIC_PT_MIN || payloadTypeInt > AVProfile.DYNAMIC_PT_MAX) {
					// static payload type
					format = AVProfile.getFormat(payloadTypeInt, AVProfile.AUDIO);
				} else {
					// dynamic payload type
					final RtpMapAttribute codecSdp = media.getFormat(payloadTypeInt);
					final String codecName = codecSdp.getCodec();
					final RTPFormat staticFormat = AVProfile.getFormat(codecName);

					// Check if code is supported
					final boolean supported = staticFormat != null && staticFormat.getClockRate() == codecSdp.getClockRate();
					if(supported) {
						format = new RTPFormat(payloadTypeInt, staticFormat.getFormat(), staticFormat.getClockRate());
					} else {
						format = null;
					}
				}
			} catch (NumberFormatException e) {
        		format = null;
			}

			if(format != null) {
        		this.offeredFormats.add(format);
			} else {
        		if (logger.isDebugEnabled()) {
					logger.debug(this.mediaType + " channel " + this.ssrc + " dropped unsupported RTP payload type " + payloadType);
				}
			}
        }
		
		// Negotiate the formats and store intersection
		this.negotiatedFormats.clean();
		this.supportedFormats.intersection(this.offeredFormats, this.negotiatedFormats);
		
		// Apply formats
		setFormats(this.negotiatedFormats);
		this.negotiated = true;
	}
1291968
function (host, port) {
  this.name = 'AVTransport'
  this.host = host
  this.port = port || 1400
  this.controlURL = '/MediaRenderer/AVTransport/Control'
  this.eventSubURL = '/MediaRenderer/AVTransport/Event'
  this.SCPDURL = '/xml/AVTransport1.xml'
}
1369654
def _release_media_transport(self, path, access_type):
        
        try:
            self._uninstall_transport_ready()
            os.close(self.fd)   # Clean-up previously taken fd
            transport = BTMediaTransport(path=path)
            transport.release(access_type)
        except:
            pass