# Control HTTP origin session creation with the Wowza Streaming Engine Java API

Updated on 04/19/2019 10:30 am PDT

Wowza Streaming Engine™ media server software can be configured as an HTTP origin for stream delivery. When in HTTP origin mode, Wowza Streaming Engine combines all sessions with a given stream name into a single session by default. This is problematic if you're using certain features, such as **wowzaplaystart** and **wowzaplayduration** query parameters, to control playback because while these features are in use, the proper start and duration aren't tracked in the single session for viewers that are using different values. However, the **IHTTPStreamerHTTPOriginSessionIdProvider** API hook enables you to control the **httpOriginId**, which is used to combine sessions and determine if a session is unique. This article demonstrates how to create unique sessions for an Apple HLS (cupertino) stream using the **IHTTPStreamerHTTPOriginSessionIdProvider** API hook and the **wowzaplaystart** and **wowzaplayduration** query parameters.

> **Notes:**
>
> - Wowza Streaming Engine 4.4.0 or later is required to use the **IHTTPStreamerHTTPOriginSessionIdProvider** API hook to control HTTP origin session creation and combination.
>
> - The **IHTTPStreamerHTTPOriginSessionIdProvider** API hook won't work properly if you require different behaviors based on the query parameter, such as **wowzaplaystart** or **wowzaplayduration**.

Copy

```java
import java.util.*;

import com.wowza.util.*;
import com.wowza.wms.application.*;
import com.wowza.wms.http.*;
import com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.*;
import com.wowza.wms.httpstreamer.model.*;
import com.wowza.wms.httpstreamer.util.*;
import com.wowza.wms.module.*;
import com.wowza.wms.vhost.*;

public class ModuleTestHTTPOriginSessionIdProvider extends ModuleBase
{
    class MyHTTPOriginSessionIdProvider implements IHTTPStreamerHTTPOriginSessionIdProvider
    {
        HTTPStreamerApplicationContextCupertinoStreamer appContextCupertino = null;
        HTTPStreamerAdapterCupertinoStreamer  streamAdapterCupertino = null;

public MyHTTPOriginSessionIdProvider(HTTPStreamerApplicationContextCupertinoStreamer appContextCupertino, HTTPStreamerAdapterCupertinoStreamer  streamAdapterCupertino)
        {
            this.appContextCupertino = appContextCupertino;
            this.streamAdapterCupertino = streamAdapterCupertino;
        }

public String getHTTPOriginId(String httpOriginId, IHTTPRequest req, IHTTPStreamerApplicationContext appContext, String oldSessionId, String streamDomainStr, boolean isHTTPOrigin, boolean isDvr, long currTime)
        {
            long playStart = 0;
            long playDuration = -1;

String queryStr = req.getQueryString();
            if (queryStr != null)
            {
                Map<String, String> queryMap = HTTPUtils.splitQueryStr(queryStr);

String playStartStr = queryMap.get(streamAdapterCupertino.getPlayStartQueryParameter());
                if (playStartStr != null)
                {
                    try
                    {
                        playStart = Long.parseLong(playStartStr);
                    }
                    catch(Exception e)
                    {
                    }
                }

String playDurationStr = queryMap.get(streamAdapterCupertino.getPlayDurationQueryParameter());
                if (playDurationStr != null)
                {
                    try
                    {
                        playDuration = Long.parseLong(playDurationStr);
                    }
                    catch(Exception e)
                    {
                    }
                }
            }

httpOriginId = httpOriginId+"|playStart="+playStart+"|playDuration="+playDuration;

getLogger().info("ModuleTestHTTPOriginSessionIdProvider#MyHTTPOriginSessionIdProvider.getHTTPOriginId:"+httpOriginId);

return httpOriginId;
        }
    }

public void onAppStart(IApplicationInstance appInstance)
    {
        getLogger().info("ModuleTestHTTPOriginSessionIdProvider.onAppStart["+appInstance.getContextStr()+"]");

IVHost vhost = appInstance.getVHost();

String adapterName = HTTPStreamerUtils.httpSessionProtocolToName(IHTTPStreamerSession.SESSIONPROTOCOL_CUPERTINOSTREAMING);

IHTTPStreamerApplicationContext appContext = appInstance.getHTTPStreamerApplicationContext(adapterName, true);
        IHTTPStreamerAdapter streamerAdapter = vhost.getHTTPStreamerAdapter(adapterName);

if (appContext != null && streamerAdapter != null)
        {
            MyHTTPOriginSessionIdProvider httpOriginSessionIdProvider = new MyHTTPOriginSessionIdProvider((HTTPStreamerApplicationContextCupertinoStreamer)appContext, (HTTPStreamerAdapterCupertinoStreamer)streamerAdapter);

appContext.setHTTPOriginSessionIdProvider(httpOriginSessionIdProvider);
        }
    }
}
```

## More resources [Copy to clipboard](/content/docs/how-to-control-http-origin-session-creation\#more-resources "Copy to clipboard"/index.html)

* * *

- [Configure Wowza Streaming Engine as an HTTP caching origin](/content/docs/How-to-configure-a-Wowza-server-as-an-HTTP-caching-origin/index.html)

- [Scaling with Wowza HTTP Origin applications](/content/docs/Scaling-with-Wowza-HTTP-Origin-applications/index.html)

Was this article helpful?

[Helpful](/content/docs/how-to-control-http-origin-session-creation# "Helpful"/index.html)

Thank you for your feedback!

300 characters remaining

Name

Email

reCAPTCHA

Recaptcha requires verification.

I'm not a robot

reCAPTCHA

[Submit](/content/docs/how-to-control-http-origin-session-creation# "Submit comment"/index.html)

Thank you for providing feedback to help us improve our documentation!

##### Popular Video Topics [Copy to clipboard](/content/docs/how-to-control-http-origin-session-creation\#popular-video-topics "Copy to clipboard"/index.html)

- [The Future of Video Tech](/content/blog/future-of-video-technology/index.html)
- [Streaming Starter Guide](/content/blog/complete-guide-to-live-streaming/index.html)
- [Live Event Streaming Guide](/content/blog/live-event-streaming-guide/index.html)
- [Interactive Streaming Guide](/content/blog/low-latency-streaming-technologies-the-key-to-interactive-video/index.html)
- [Streaming Protocols](/content/blog/streaming-protocols/index.html)
- [Transcoding](/content/blog/what-is-transcoding-and-why-its-critical-for-streaming/index.html)
- [Low Latency](/content/blog/what-is-low-latency/index.html)
- [Security](/content/blog/secure-video-streaming/index.html)

##### Video Resources [Copy to clipboard](/content/docs/how-to-control-http-origin-session-creation\#video-resources "Copy to clipboard"/index.html)

- [APIs & SDKs](/content/docs/wowza-developer-apis-and-sdks/index.html)
- [Developer IDE](/content/docs/how-to-extend-wowza-streaming-engine-using-the-wowza-ide/index.html)
- [Test Players](/content/testplayers/index.html)
- [Wowza System Status](https://status.wowza.com/)

##### Partners [Copy to clipboard](/content/docs/how-to-control-http-origin-session-creation\#partners "Copy to clipboard"/index.html)

- [Partners Overview](/content/partners/index.html)
- [Find a Partner](/content/partners/preferred-international-resellers/index.html)
- [Channel Program](/content/partners/channel-partner-program/index.html)
- [OEM Program](/content/partners/oem/index.html)
- [Partner Portal](/content/partners/resources/index.html)

##### Company [Copy to clipboard](/content/docs/how-to-control-http-origin-session-creation\#company "Copy to clipboard"/index.html)

- [About Us](/content/company/index.html)
- [Blog](/content/blog/category/blog/index.html)
- [News](/content/news/index.html)
- [Events & Webinars](/content/company/events/index.html)
- [Careers](/content/careers/index.html)
- [Customers](/content/customers/index.html)
- [Contact Us](/content/contact/index.html)

##### Stay Connected [Copy to clipboard](/content/docs/how-to-control-http-origin-session-creation\#stay-connected "Copy to clipboard"/index.html)

##### Stay Up to Date with the Blog [Copy to clipboard](/content/docs/how-to-control-http-origin-session-creation\#stay-up-to-date-with-the-blog "Copy to clipboard"/index.html)

Email

X - Form Filled Type

© 2007–2025 Wowza Media Systems™, LLC. All rights reserved.   [Security & Privacy Policy](/content/legal/privacy/index.html) \| [Legal](/content/legal/index.html) \| [System Status](https://status.wowza.com/)

reCAPTCHA
