# IMediaStream

**URL:** <https://community.wowza.com/t/imediastream/36478>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [June 2, 2015, 10:50am UTC](https://community.wowza.com/t/imediastream/36478 "2015-06-02T10:50:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Janez\_Makovsek](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@Janez\_Makovsek](https://community.wowza.com/u/Janez_Makovsek)\
**Post date:** [June 2, 2015, 10:50am UTC](https://community.wowza.com/t/imediastream/36478/1 "2015-06-02T10:50:48Z")

</div>

Hi!

I have:

import com.wowza.wms.stream.publish.Stream;

…

private Stream MyStream;

…

How can I obtain IMediaStream which is associated with the MyStream? I need IMediaStream to insert live captions:

public void sendTextDataMessage(IMediaStream stream, OnTextData onTextData)

{

…

}

Thanks!

Atmapuri

---

<div class="post-metadata">

**Author:** ![Janez\_Makovsek](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@Janez\_Makovsek](https://community.wowza.com/u/Janez_Makovsek)\
**Post date:** [June 2, 2015, 4:48pm UTC](https://community.wowza.com/t/imediastream/36478/2 "2015-06-02T16:48:34Z")

</div>

> Hi!
> 
> I have:
> 
> import com.wowza.wms.stream.publish.Stream;
> 
> …
> 
> private Stream MyStream;
> 
> …
> 
> How can I obtain IMediaStream which is associated with the MyStream? I need IMediaStream to insert live captions:
> 
> Ok, found a solution for that:
> 
> IMediaStream stream = publishedStream.getPublisher().getStream();
> 
> Now, the question. Are these two lines thread safe:
> 
> stream.sendDirect(“onTextData”, amfData);
> 
> ((MediaStream)stream).processSendDirectMessages();
> 
> In the sense that I could have multiple clients calling these two lines each client from their own thread but all using the same stream object? Or is a lock required?
> 
> Thanks!
> 
> Atmapuri
