Skip to content

Commit

Permalink
[WIP] devtools の h265_params 対応
Browse files Browse the repository at this point in the history
  • Loading branch information
tnamao committed Dec 1, 2023
1 parent d817293 commit 960578b
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ export const setInitialParameter = () => {
if (qsParams.videoH264Params !== undefined) {
dispatch(slice.actions.setVideoH264Params(qsParams.videoH264Params))
}
if (qsParams.videoH265Params !== undefined) {
dispatch(slice.actions.setVideoH265Params(qsParams.videoH265Params))
}
if (qsParams.videoAV1Params !== undefined) {
dispatch(slice.actions.setVideoAV1Params(qsParams.videoAV1Params))
}
Expand Down Expand Up @@ -256,6 +259,7 @@ export const setInitialParameter = () => {
forwardingFilter,
videoVP9Params,
videoH264Params,
videoH265Params,
videoAV1Params,
} = getState()
if (e2ee) {
Expand Down Expand Up @@ -316,6 +320,10 @@ export const setInitialParameter = () => {
if (videoH264Params !== '') {
dispatch(slice.actions.setEnabledVideoH264Params(true))
}
// videoH265Params が存在した場合は enabledH265Params をセットする
if (videoH265Params !== '') {
dispatch(slice.actions.setEnabledVideoH265Params(true))
}
// videoAV1Params が存在した場合は enabledVideoAV1Params をセットする
if (videoAV1Params !== '') {
dispatch(slice.actions.setEnabledVideoAV1Params(true))
Expand Down Expand Up @@ -358,6 +366,10 @@ export const copyURL = () => {
appendAudioVideoParams && state.videoH264Params !== '' && state.enabledVideoH264Params
? state.videoH264Params
: undefined,
videoH265Params:
appendAudioVideoParams && state.videoH265Params !== '' && state.enabledVideoH265Params
? state.videoH265Params
: undefined,
videoAV1Params:
appendAudioVideoParams && state.videoAV1Params !== '' && state.enabledVideoAV1Params
? state.videoAV1Params
Expand Down Expand Up @@ -958,6 +970,7 @@ function pickConnectionOptionsState(state: SoraDevtoolsState): ConnectionOptions
enabledForwardingFilter: state.enabledForwardingFilter,
enabledVideoVP9Params: state.enabledVideoVP9Params,
enabledVideoH264Params: state.enabledVideoH264Params,
enabledVideoH265Params: state.enabledVideoH265Params,
enabledVideoAV1Params: state.enabledVideoAV1Params,
ignoreDisconnectWebSocket: state.ignoreDisconnectWebSocket,
audioLyraParamsBitrate: state.audioLyraParamsBitrate,
Expand All @@ -975,6 +988,7 @@ function pickConnectionOptionsState(state: SoraDevtoolsState): ConnectionOptions
videoCodecType: state.videoCodecType,
videoVP9Params: state.videoVP9Params,
videoH264Params: state.videoH264Params,
videoH265Params: state.videoH265Params,
videoAV1Params: state.videoAV1Params,
role: state.role,
}
Expand Down Expand Up @@ -1889,6 +1903,7 @@ export const {
setEnabledSignalingUrlCandidates,
setEnabledVideoVP9Params,
setEnabledVideoH264Params,
setEnabledVideoH265Params,
setEnabledVideoAV1Params,
setAudioStreamingLanguageCode,
setEnabledAudioStreamingLanguageCode,
Expand Down Expand Up @@ -1931,5 +1946,6 @@ export const {
setVideoTrack,
setVideoVP9Params,
setVideoH264Params,
setVideoH265Params,
setVideoAV1Params,
} = slice.actions
8 changes: 8 additions & 0 deletions src/app/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const initialState: SoraDevtoolsState = {
enabledSignalingUrlCandidates: false,
enabledVideoVP9Params: false,
enabledVideoH264Params: false,
enabledVideoH265Params: false,
enabledVideoAV1Params: false,
audioStreamingLanguageCode: '',
enabledAudioStreamingLanguageCode: false,
Expand Down Expand Up @@ -115,6 +116,7 @@ const initialState: SoraDevtoolsState = {
videoInputDevices: [],
videoVP9Params: '',
videoH264Params: '',
videoH265Params: '',
videoAV1Params: '',
version: packageJSON.version,
cameraDevice: true,
Expand Down Expand Up @@ -244,6 +246,9 @@ export const slice = createSlice({
setEnabledVideoH264Params: (state, action: PayloadAction<boolean>) => {
state.enabledVideoH264Params = action.payload
},
setEnabledVideoH265Params: (state, action: PayloadAction<boolean>) => {
state.enabledVideoH265Params = action.payload
},
setEnabledVideoAV1Params: (state, action: PayloadAction<boolean>) => {
state.enabledVideoAV1Params = action.payload
},
Expand Down Expand Up @@ -354,6 +359,9 @@ export const slice = createSlice({
setVideoH264Params: (state, action: PayloadAction<string>) => {
state.videoH264Params = action.payload
},
setVideoH265Params: (state, action: PayloadAction<string>) => {
state.videoH265Params = action.payload
},
setVideoAV1Params: (state, action: PayloadAction<string>) => {
state.videoAV1Params = action.payload
},
Expand Down
58 changes: 58 additions & 0 deletions src/components/DevtoolsPane/VideoH265ParamsForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react'
import { Col, FormControl, FormGroup, Row } from 'react-bootstrap'

import { setEnabledVideoH265Params, setVideoH265Params } from '@/app/actions'
import { useAppDispatch, useAppSelector } from '@/app/hooks'
import { isFormDisabled } from '@/utils'

import { TooltipFormCheck } from './TooltipFormCheck'

export const VideoH265ParamsForm: React.FC = () => {
const enabledVideoH265Params = useAppSelector((state) => state.enabledVideoH265Params)
const videoH265Params = useAppSelector((state) => state.videoH265Params)
const connectionStatus = useAppSelector((state) => state.soraContents.connectionStatus)
const disabled = isFormDisabled(connectionStatus)
const dispatch = useAppDispatch()
const onChangeSwitch = (event: React.ChangeEvent<HTMLInputElement>): void => {
dispatch(setEnabledVideoH265Params(event.target.checked))
}
const onChangeText = (event: React.ChangeEvent<HTMLInputElement>): void => {
dispatch(setVideoH265Params(event.target.value))
}
return (
<>
<Row className="form-row">
<Col className="col-auto">
<FormGroup className="form-inline" controlId="enabledVideoH265Params">
<TooltipFormCheck
kind="videoH265Params"
checked={enabledVideoH265Params}
onChange={onChangeSwitch}
disabled={disabled}
>
videoH265Params
</TooltipFormCheck>
</FormGroup>
</Col>
</Row>
{enabledVideoH265Params ? (
<Row className="form-row">
<Col className="col-auto">
<FormGroup className="form-inline" controlId="videoH265Params">
<FormControl
className="flex-fill"
as="textarea"
placeholder="videoH265Paramsを指定"
value={videoH265Params}
onChange={onChangeText}
rows={10}
cols={100}
disabled={disabled}
/>
</FormGroup>
</Col>
</Row>
) : null}
</>
)
}
4 changes: 4 additions & 0 deletions src/components/DevtoolsPane/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { VideoCodecTypeForm } from './VideoCodecTypeForm'
import { VideoContentHintForm } from './VideoContentHintForm'
import { VideoForm } from './VideoForm'
import { VideoH264ParamsForm } from './VideoH264ParamsForm'
import { VideoH265ParamsForm } from './VideoH265ParamsForm'
import { VideoInputForm } from './VideoInputForm'
import { VideoTrackForm } from './VideoTrackForm'
import { VideoVP9ParamsForm } from './VideoVP9ParamsForm'
Expand Down Expand Up @@ -240,12 +241,14 @@ const RowAdvancedSignalingOptions: React.FC = () => {
const audioLyraParamsBitrate = useAppSelector((state) => state.audioLyraParamsBitrate)
const enabledVideoVP9Params = useAppSelector((state) => state.enabledVideoVP9Params)
const enabledVideoH264Params = useAppSelector((state) => state.enabledVideoH264Params)
const enabledVideoH265Params = useAppSelector((state) => state.enabledVideoH265Params)
const enabledVideoAV1Params = useAppSelector((state) => state.enabledVideoAV1Params)
const enabledOptions = [
audioStreamingLanguageCode !== '',
audioLyraParamsBitrate !== '',
enabledVideoVP9Params,
enabledVideoH264Params,
enabledVideoH265Params,
enabledVideoAV1Params,
].some((e) => e)
const linkClassNames = ['btn-collapse-options']
Expand Down Expand Up @@ -278,6 +281,7 @@ const RowAdvancedSignalingOptions: React.FC = () => {
<VideoVP9ParamsForm />
<VideoAV1ParamsForm />
<VideoH264ParamsForm />
<VideoH265ParamsForm />
</div>
</Collapse>
</Row>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Header/DownloadReportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function createDownloadReport(): DownloadReport {
enabledSignalingUrlCandidates: state.enabledSignalingUrlCandidates,
enabledVideoVP9Params: state.enabledVideoVP9Params,
enabledVideoH264Params: state.enabledVideoH264Params,
enabledVideoH265Params: state.enabledVideoH265Params,
enabledVideoAV1Params: state.enabledVideoAV1Params,
facingMode: state.facingMode,
fakeVolume: state.fakeVolume,
Expand Down Expand Up @@ -75,6 +76,7 @@ function createDownloadReport(): DownloadReport {
videoTrack: state.videoTrack,
videoVP9Params: state.videoVP9Params,
videoH264Params: state.videoH264Params,
videoH265Params: state.videoH265Params,
videoAV1Params: state.videoAV1Params,
}
const report = {
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export type SoraDevtoolsState = {
enabledForwardingFilter: boolean
enabledVideoVP9Params: boolean
enabledVideoH264Params: boolean
enabledVideoH265Params: boolean
enabledVideoAV1Params: boolean
audioStreamingLanguageCode: string
enabledAudioStreamingLanguageCode: boolean
Expand Down Expand Up @@ -137,6 +138,7 @@ export type SoraDevtoolsState = {
videoInputDevices: MediaDeviceInfo[]
videoVP9Params: string
videoH264Params: string
videoH265Params: string
videoAV1Params: string
version: string
cameraDevice: boolean
Expand Down Expand Up @@ -346,6 +348,7 @@ export type ConnectionOptionsState = Pick<
| 'enabledForwardingFilter'
| 'enabledVideoVP9Params'
| 'enabledVideoH264Params'
| 'enabledVideoH265Params'
| 'enabledVideoAV1Params'
| 'ignoreDisconnectWebSocket'
| 'audioLyraParamsBitrate'
Expand All @@ -363,6 +366,7 @@ export type ConnectionOptionsState = Pick<
| 'videoCodecType'
| 'videoVP9Params'
| 'videoH264Params'
| 'videoH265Params'
| 'videoAV1Params'
| 'role'
>
Expand Down
8 changes: 8 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export function parseQueryString(): Partial<QueryStringParameters> {
videoCodecType: parseSpecifiedStringParameter(qs.videoCodecType, VIDEO_CODEC_TYPES),
videoVP9Params: parseStringParameter(qs.videoVP9Params),
videoH264Params: parseStringParameter(qs.videoH264Params),
videoH265Params: parseStringParameter(qs.videoH265Params),
videoAV1Params: parseStringParameter(qs.videoAV1Params),
audioInput: parseStringParameter(qs.audioInput),
videoInput: parseStringParameter(qs.videoInput),
Expand Down Expand Up @@ -703,6 +704,13 @@ export function createConnectOptions(
connectionOptionsState.videoH264Params,
)
}
// videoH265Params
if (connectionOptionsState.enabledVideoH265Params) {
connectionOptions.videoH265Params = parseMetadata(
true,
connectionOptionsState.videoH265Params,
)
}
// videoVP9Params
if (connectionOptionsState.enabledVideoAV1Params) {
connectionOptions.videoAV1Params = parseMetadata(true, connectionOptionsState.videoAV1Params)
Expand Down

0 comments on commit 960578b

Please sign in to comment.