Skip to content

Commit a226f39

Browse files
committed
Merge pull request #73 from jeffswartz/docs
Docs for new features in the archiving sample.
2 parents b004a7c + 80400ee commit a226f39

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

sample/Archiving/README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,25 @@ generates the three strings that the client (JavaScript) needs to connect to the
8181
URL. The route handler for this URL is shown below:
8282

8383
```java
84-
get(new Route("/start") {
84+
post(new Route("/start") {
8585
@Override
8686
public Object handle(Request request, Response response) {
8787

8888
Archive archive = null;
89+
HttpServletRequest req = request.raw();
90+
boolean hasAudio = req.getParameterMap().containsKey("hasAudio");
91+
boolean hasVideo = req.getParameterMap().containsKey("hasVideo");
92+
OutputMode outputMode = OutputMode.COMPOSED;
93+
if (req.getParameter("outputMode").equals("individual")) {
94+
outputMode = OutputMode.INDIVIDUAL;
95+
}
8996
try {
90-
archive = opentok.startArchive(sessionId, "Java Archiving Sample App");
97+
ArchiveProperties properties = new ArchiveProperties.Builder()
98+
.name("Java Archiving Sample App")
99+
.hasAudio(hasAudio)
100+
.hasVideo(hasVideo)
101+
.outputMode(outputMode).build();
102+
archive = opentok.startArchive(sessionId, properties);
91103
} catch (OpenTokException e) {
92104
e.printStackTrace();
93105
return null;
@@ -98,8 +110,11 @@ get(new Route("/start") {
98110
```
99111

100112
In this handler, the `startArchive()` method of the `opentok` instance is called with the `sessionId`
101-
for the session that needs to be archived. The optional second argument is `name`, which is stored with
102-
the archive and can be read later. In this case, as in the HelloWorld sample app, there is
113+
for the session that needs to be archived. An ArchiveProperties object is instantiated. It defines
114+
optional properties for the archive. The `name` is stored with the archive and can be read later.
115+
The `hasAudio`, `hasVideo`, and `outputMode` values are read from the request body; these define
116+
whether the archive will record audio and video, and whether it will record streams individually or
117+
to a single file composed of all streams. In this case, as in the HelloWorld sample app, there is
103118
only one session created and it is used here and for the participant view. This will trigger the
104119
recording to begin. The response sent back to the client's XHR request will be the JSON
105120
representation of the archive, which is returned from the `toString()` method. The client is also

0 commit comments

Comments
 (0)