---
title: {{ page_meta.name }}｜{{ group.public_title }}｜{{ site_settings.logo_alt }}
description: ビデオ通話やライブ配信を簡単に実装できるAgora SDK。ビデオ通話アプリ（DualStream）の実装例・サンプルコードです。
---

[Agora Go Real ](https://jp.vcube.com/sdk/blog)

# [{{ page_meta.name }}｜{{ group.public_title }}｜{{ site_settings.logo_alt }}](https://jp.vcube.com/sdk/blog/implementation-dualstream.html)

 作成者: [ブイキューブ](https://jp.vcube.com/sdk/blog/author/v-cube)｜May 13, 2022 7:43:47 AM

## DualStreamの使い所

- NW環境が厳しい場合に最低限音声だけ快適に聞こえるようにしたい
- 720P<->90Pで画角を動的に変更するようなUI/UXの場合

## 作成するアプリ

- 高画質,低画質をボタンで切り替える
- 取得している映像情報を表示する

## 開発環境

macOS Mojave 10.14.1  
VisualStudioCode 1.29.1  
Chrome 70.0.3538.102  
AgoraVideoSDK for Web 2.5.0

## 使用するAPI

```
enableDualStream(onSuccess: function, onFailure: function): void
    setRemoteVideoStreamType(stream: Stream, streamType: 0 | 1): void
    setLowStreamParameter(param: object): void //オプション
    
```

## 実装内容

基本的にはDualStreamの有効化と高画質or低画質の切り替えです。  
最初は低画質の設定無しで試してみます。  
GitHubに公開しています。

- [AgoraIO-DualStream（GitHub）](https://github.com/fu-jimoto/AgoraIO-DualStream)

```
client.init(app_id, function () {
      client.join("", "demo", null, function(uid) {
        client.enableDualStream(function() {//DualStreamの有効化
          //client.setLowStreamParameter({birate:140, framerate:10, height:180, width:320});
          console.log("enable dual stream success.");
        }, function(err) {
        });
    
        localStream = AgoraRTC.createStream({streamID: uid, audio: true, video:true, screen: false});
        localStream.setVideoProfile("720p");
        localStream.init(function() {
          client.publish(localStream, function (err) {});
        }, function (err) {});
    
      }, function(err) {});
    }, function (err) {});
    
    function chengeStream(streamType){
      client.setRemoteVideoStreamType(remoteStream, streamType);//画質切り替え
    }
    
    setInterval(function() {//2秒毎に品質をログに出力
      if(remoteStream){
        remoteStream.getStats(function(stats){
        console.log("---------------");
        for(var i in stats){
          console.log(i+":"+stats[i]);
        }
      });
      }
    }, 2000);
    
```

### デフォルトの画質（720P）

画角が1280x720で受信されています。

### 低画質（90P）

画角が160x90で受信されています。

### 低画質の画角指定（180P）

画角が320x180Pで受信されています。

## 補足

今回はWebSDKでの紹介でしたが、Native用のSDKでも同様の実装が可能です。

[そのほか、最新の実装例・サンプルコード記事はこちら](https://qiita.com/v-cube)

[完全な記事を表示](https://jp.vcube.com/sdk/blog/implementation-dualstream.html)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "ブイキューブ"
  },
  "dateModified" : "2022-05-13T07:43:47.814Z",
  "datePublished" : "2022-05-13T07:43:47Z",
  "headline" : "実装例｜DualStreamの実装",
  "image" : {
    "@type" : "ImageObject",
    "height" : 959,
    "url" : "https://1970584.fs1.hubspotusercontent-na1.net/hubfs/1970584/solution/sdk/blog/implementation-dualstream/agora_implementation-dualstream01.png",
    "width" : 1476
  },
  "mainEntityOfPage" : "https://jp.vcube.com/sdk/blog/implementation-dualstream.html",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Agora Go Real"
  }
}
```