09.02.2013 Views

Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...

Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...

Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

88<br />

/**<br />

* creazione sessione <strong>per</strong> ogni track<br />

*/<br />

private String createTransmitter() {<br />

}<br />

<strong>Sviluppo</strong> <strong>di</strong> <strong>una</strong> <strong>piattaforma</strong> <strong>per</strong> <strong>lo</strong> <strong>streaming</strong> multime<strong>di</strong>ale in ambiente Android<br />

// Cheated. Should have checked the type.<br />

PushBufferDataSource pbds = (PushBufferDataSource) dataOutput;<br />

PushBufferStream pbss[] = pbds.getStreams();<br />

rtpMgrs = new RTPManager[pbss.length];<br />

SessionAddress <strong>lo</strong>calAddr, destAddr;<br />

InetAddress ipAddr;<br />

SendStream sendStream;<br />

int port;<br />

SourceDescription srcDesList[];<br />

for (int i = 0; i < pbss.length; i++) {<br />

try {<br />

rtpMgrs[i] = RTPManager.newInstance();<br />

port = portBase + 2 * i;<br />

<strong>lo</strong>calAddr = new<br />

SessionAddress(InetAddress.getLocalHost(), port);<br />

System.err.println("in<strong>di</strong>rizzo origine: " + <strong>lo</strong>calAddr);<br />

rtpMgrs[i].initialize(<strong>lo</strong>calAddr);<br />

// la porta <strong>di</strong> <strong>lo</strong>cal è la stessa da cui trasmetto e ricevo l'rtcp<br />

destAddr = new<br />

SessionAddress(InetAddress.getLocalHost(), 11001);<br />

System.err.println("in<strong>di</strong>rizzo destinazione: "+destAddr);<br />

rtpMgrs[i].addTarget(destAddr);<br />

System.err.println("CreataSessionRTP:"+rtpMgrs[i]+" " +port);<br />

sendStream = rtpMgrs[i].createSendStream(dataOutput, i);<br />

System.err.println("Avvio <strong>lo</strong> stream");<br />

sendStream.start();<br />

} catch (Exception e) {<br />

e.printStackTrace();<br />

}<br />

}<br />

return null;<br />

/**<br />

* For JPEG and H263, we know that they only work for particular sizes.<br />

* we'll <strong>per</strong>form extra checking here to make sure they are of the right<br />

* sizes.<br />

*/<br />

Format checkForVideoSizes(Format original, Format supported) {<br />

int width, height;<br />

Dimension size = ((VideoFormat) original).getSize();<br />

Format jpegFmt = new Format(VideoFormat.JPEG_RTP);<br />

Format h263Fmt = new Format(VideoFormat.H263_RTP);<br />

if (supported.matches(jpegFmt)) {<br />

// For JPEG, make sure width and height are <strong>di</strong>visible by 8.<br />

width = (size.width % 8 == 0 ? size.width<br />

: (int) (size.width / 8) * 8);<br />

height = (size.height % 8 == 0 ? size.height<br />

: (int) (size.height / 8) * 8);<br />

} else if (supported.matches(h263Fmt)) {

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!