> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-auto-generate-llmstxt.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Move from Stream to Room

> Plan SDK code changes when moving livestream integrations from legacy Stream APIs to room-based live experiences.

Use room APIs for new livestream and co-host experiences. Legacy Stream APIs still exist in the audited SDK sources, so treat this page as an application migration checklist rather than a removal timeline or data-migration promise.

<Note>
  This page focuses on SDK code paths only. UIKit, Admin Console, backend API behavior, commercial timelines, and product analytics dashboards are outside this SDK-first migration guide.
</Note>

## Migration Scope

| Area             | Keep legacy Stream support for                                                      | Move new work to Room APIs                                                                    |
| ---------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| Existing content | Existing Stream posts and playback screens that your product still needs to support | New live room and co-host experiences                                                         |
| Entity model     | `AmityStream` / `streamId`                                                          | `AmityRoom` / `roomId`                                                                        |
| Feed post type   | Legacy live stream post data                                                        | Room post data with `roomId`                                                                  |
| Playback source  | Stream watcher or recording data                                                    | `livePlaybackUrl` and `recordedPlaybackInfos` / `recordedData` / `getRecordedPlaybackInfos()` |
| Watch analytics  | Legacy stream-session logic where still used                                        | `room.analytics()` watch-session APIs                                                         |

<Warning>
  Do not delete legacy Stream handling until every screen that can display old Stream posts has a fallback path. A migration usually means supporting both old Stream content and new Room content during rollout.
</Warning>

## Platform Surface

| Platform   | Legacy Stream surface found                                                      | Room surface found                                                         | Room post creation                                                 | Migration note                                                                          |
| ---------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
| TypeScript | `StreamRepository`, `Amity.Stream`, `streamId` fields in legacy surfaces         | `RoomRepository`, `Amity.Room`                                             | `PostRepository.createRoomPost()`                                  | Use room APIs for new rooms and keep stream handling for old posts.                     |
| iOS        | `AmityStreamRepository`, `AmityStream`                                           | `AmityRoomRepository`, `AmityRoom`                                         | `AmityPostRepository.createRoomPost()` with `AmityRoomPostBuilder` | Retain `AmityNotificationToken` values while observing live objects or collections.     |
| Android    | `AmityVideoClient.newStreamRepository()`, `AmityStreamRepository`, `AmityStream` | `AmityVideoClient.newRoomRepository()`, `AmityRoomRepository`, `AmityRoom` | `AmityPostRepository.createRoomPost()`                             | Room APIs return Rx types; dispose subscriptions with your app lifecycle.               |
| Flutter    | Legacy `AmityVideoClient.newStreamRepository()` and `StreamRepository`           | No current public room broadcasting repository found in this audit         | No current public room post creator found in this audit            | Do not promise a Flutter room migration path from SDK docs until the public API exists. |

## Concept Mapping

| Legacy Stream concept           | Room-based concept                     | What changes in app code                                                                 |
| ------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------- |
| `streamId`                      | `roomId`                               | Store and pass room IDs for new room content. Keep stream IDs for legacy content.        |
| `AmityStream`                   | `AmityRoom`                            | Read room status, participants, playback URLs, and recorded metadata from room models.   |
| Stream repository               | Room repository                        | Use `RoomRepository` / `AmityRoomRepository` / `newRoomRepository()` for new room flows. |
| Legacy live stream post         | Room post                              | Create a room first, then create a room post that references the `roomId`.               |
| Stream watcher URL / recordings | Room live and recorded playback fields | Pass SDK-returned room playback URLs to your app-owned player.                           |
| Stream session analytics        | Room watch-session analytics           | Use `room.analytics()` for new room watch sessions.                                      |

## Parameters

| Operation            | Parameter                  | Required | Platforms                | Description                                                                     |
| -------------------- | -------------------------- | -------- | ------------------------ | ------------------------------------------------------------------------------- |
| Observe room content | `roomId`                   | Yes      | TypeScript, iOS, Android | Room ID used when replacing new Stream observation flows with room observation. |
| Create room          | Room options               | Yes      | TypeScript, iOS, Android | Room title and configuration passed to the room repository.                     |
| Publish room post    | `communityId` or target ID | Yes      | TypeScript, iOS, Android | Feed target where the room post should be published.                            |
| Publish room post    | `roomId`                   | Yes      | TypeScript, iOS, Android | Room ID returned by room creation and embedded in the room post.                |
| Publish room post    | Text or title fields       | No       | TypeScript, iOS, Android | Display text used by the feed post that references the room.                    |

## Observe Room Content

Replace new Stream observation flows with room observation for new room-based screens. Each snippet below is standalone and uses the current room repository surface.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { RoomRepository } from "@amityco/ts-sdk";

  function observeRoomForMigration(roomId: string): Amity.Unsubscriber {
    return RoomRepository.getRoom(roomId, snapshot => {
      if (snapshot.error) {
        handleError(snapshot.error);
        return;
      }

      const room = snapshot.data;
      showSuccessMessage(room.status);
    });
  }
  ```

  ```kotlin Android theme={null}
  import com.amity.socialcloud.sdk.api.video.AmityVideoClient

  val disposable = AmityVideoClient.newRoomRepository()
      .getRoom(roomId)
      .subscribe(
          { room -> showSuccessMessage(room.getStatus()) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```swift iOS theme={null}
  var roomObservationToken: AmityNotificationToken?
  let roomObject = AmityRoomRepository().getRoom(withId: roomId)

  roomObservationToken = roomObject.observe { liveObject, error in
      if let error {
          handleGeneralError(error)
          return
      }

      if let room = liveObject.snapshot {
          showSuccessMessage(room.status.rawValue)
      }
  }
  ```
</CodeGroup>

## Create and Publish a Room

For new room-based livestreams, create the room first. Publish it into a user or community feed by creating a room post with the returned `roomId`.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { PostRepository, RoomRepository } from "@amityco/ts-sdk";

  async function createAndPublishRoom(communityId: string): Promise<string> {
    const { data: room } = await RoomRepository.createRoom({
      title: "Live room",
      liveChatEnabled: true,
      type: "coHosts",
    });

    const { data: post } = await PostRepository.createRoomPost({
      targetType: "community",
      targetId: communityId,
      data: {
        roomId: room.roomId,
        text: "Join this live room",
        title: "Live room",
      },
    });

    showSuccessMessage(post.postId);

    return post.postId;
  }
  ```

  ```kotlin Android theme={null}
  import com.amity.socialcloud.sdk.api.social.AmitySocialClient
  import com.amity.socialcloud.sdk.api.video.AmityVideoClient
  import com.amity.socialcloud.sdk.model.social.post.AmityPost

  val postRepository = AmitySocialClient.newPostRepository()

  val disposable = AmityVideoClient.newRoomRepository()
      .createRoom(
          title = "Live room",
          liveChatEnabled = true
      )
      .flatMap { room ->
          postRepository.createRoomPost(
              targetType = AmityPost.TargetType.COMMUNITY,
              targetId = communityId,
              roomId = room.getRoomId(),
              text = "Join this live room",
              title = "Live room"
          )
      }
      .subscribe(
          { post -> showSuccessMessage(post.getPostId()) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```swift iOS theme={null}
  func createAndPublishRoom(communityId: String) async throws -> String {
      let options = AmityRoomCreateOptions(
          title: "Live room",
          liveChatEnabled: true,
          type: .coHosts
      )

      let room = try await AmityRoomRepository().createRoom(with: options)

      let builder = AmityRoomPostBuilder(
          roomId: room.roomId,
          text: "Join this live room"
      )
      builder.setTitle("Live room")

      let post = try await AmityPostRepository().createRoomPost(
          builder,
          targetId: communityId,
          targetType: .community,
          metadata: nil,
          mentionees: nil
      )

      showSuccessMessage(post.postId)

      return post.postId
  }
  ```
</CodeGroup>

## Migration Checkpoints

| Checkpoint     | What to verify                                                                                                  |
| -------------- | --------------------------------------------------------------------------------------------------------------- |
| Data model     | New room-backed records store `roomId`; legacy records that still point to streams keep `streamId`.             |
| Feed rendering | Feed cards branch by data type and render both legacy Stream posts and new Room posts during rollout.           |
| Playback       | New Room playback reads `livePlaybackUrl` for live rooms and recorded metadata only after `recorded` status.    |
| Broadcasting   | New broadcasts create a room and request broadcaster data before connecting your media layer.                   |
| Chat           | If your room enables live chat, fetch the room live chat channel through the room API before rendering chat UI. |
| Analytics      | Start room watch sessions only for `live` or `recorded` rooms and update watch duration from player state.      |
| Lifecycle      | Retain and dispose each platform's subscription/token/disposable with the screen lifecycle.                     |

## Rollout Strategy

1. Add room post rendering while keeping legacy Stream post rendering.
2. Create new livestreams through room APIs and create room posts for feed visibility.
3. Move playback screens to read room playback fields for room posts.
4. Wire room watch analytics after the player starts active playback.
5. Keep legacy Stream code only for content that still exists in your product.

<Info>
  Room APIs do not make the SDK own camera capture, player controls, autoplay, buffering, captions, or DRM. Those remain app and media-player responsibilities.
</Info>

## Related Topics

<CardGroup cols={3}>
  <Card title="Create Room" icon="video" href="/social-plus-sdk/video-new/broadcasting/create-room">
    Create rooms and retrieve broadcaster data.
  </Card>

  <Card title="Room Posts" icon="newspaper" href="/social-plus-sdk/social/content-management/posts/creation/room-post">
    Publish an existing room into a feed.
  </Card>

  <Card title="Playback Overview" icon="circle-play" href="/social-plus-sdk/video-new/playback/overview">
    Choose live or recorded room playback sources.
  </Card>
</CardGroup>
