Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 236 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,56 @@ components:
id:
type: string

PushTarget:
type: object
properties:
id:
type: string
description: unique identifier of the push target (UUID).
url:
type: string
description: URL of the push target.
state:
type: string
enum:
- idle
- running
- error
description: current state of the push target.
error:
type: string
description: error message if state is "error".
resolvedURL:
type: string
description: resolved URL with variables expanded.
bytesSent:
type: integer
format: int64
description: total bytes sent to the push target.

PushTargetList:
type: object
properties:
pageCount:
type: integer
format: int64
itemCount:
type: integer
format: int64
items:
type: array
items:
$ref: '#/components/schemas/PushTarget'

PushTargetAdd:
type: object
required:
- url
properties:
url:
type: string
description: URL of the push target (supports rtmp://, rtmps://).

HLSMuxer:
type: object
properties:
Expand Down Expand Up @@ -1778,6 +1828,192 @@ paths:
schema:
$ref: '#/components/schemas/Error'

/v3/paths/pushtargets/list/{name}:
get:
operationId: pushTargetsList
tags: [Paths, Push Targets]
summary: returns all push targets for a path.
description: 'Push targets are external servers to which the stream is pushed (e.g., YouTube Live, Twitch).'
parameters:
- name: name
in: path
required: true
description: name of the path.
schema:
type: string
- name: page
in: query
description: page number.
schema:
type: integer
default: 0
- name: itemsPerPage
in: query
description: items per page.
schema:
type: integer
default: 100
responses:
'200':
description: the request was successful.
content:
application/json:
schema:
$ref: '#/components/schemas/PushTargetList'
'400':
description: invalid request.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: path not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: server error.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/v3/paths/pushtargets/get/{name}/{id}:
get:
operationId: pushTargetsGet
tags: [Paths, Push Targets]
summary: returns a push target.
description: ''
parameters:
- name: name
in: path
required: true
description: name of the path.
schema:
type: string
- name: id
in: path
required: true
description: UUID of the push target.
schema:
type: string
responses:
'200':
description: the request was successful.
content:
application/json:
schema:
$ref: '#/components/schemas/PushTarget'
'400':
description: invalid request.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: path or push target not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: server error.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/v3/paths/pushtargets/add/{name}:
post:
operationId: pushTargetsAdd
tags: [Paths, Push Targets]
summary: adds a push target to a path.
description: 'Push the stream to an external server (e.g., YouTube Live, Twitch).'
parameters:
- name: name
in: path
required: true
description: name of the path.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PushTargetAdd'
responses:
'200':
description: the request was successful.
content:
application/json:
schema:
$ref: '#/components/schemas/PushTarget'
'400':
description: invalid request.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: path not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: server error.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/v3/paths/pushtargets/remove/{name}/{id}:
delete:
operationId: pushTargetsRemove
tags: [Paths, Push Targets]
summary: removes a push target from a path.
description: ''
parameters:
- name: name
in: path
required: true
description: name of the path.
schema:
type: string
- name: id
in: path
required: true
description: UUID of the push target.
schema:
type: string
responses:
'200':
description: the request was successful.
content:
application/json:
schema:
$ref: '#/components/schemas/OK'
'400':
description: invalid request.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: path or push target not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: server error.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/v3/rtspconns/list:
get:
operationId: rtspConnsList
Expand Down
5 changes: 5 additions & 0 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ func (a *API) Initialize() error {
group.GET("/paths/list", a.onPathsList)
group.GET("/paths/get/*name", a.onPathsGet)

group.GET("/paths/pushtargets/list/*name", a.onPushTargetsList)
group.GET("/paths/pushtargets/get/*name", a.onPushTargetsGet)
group.POST("/paths/pushtargets/add/*name", a.onPushTargetsAdd)
group.DELETE("/paths/pushtargets/remove/*name", a.onPushTargetsRemove)

if !interfaceIsEmpty(a.HLSServer) {
group.GET("/hlsmuxers/list", a.onHLSMuxersList)
group.GET("/hlsmuxers/get/*name", a.onHLSMuxersGet)
Expand Down
18 changes: 18 additions & 0 deletions internal/api/api_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"testing"
"time"

"github.com/google/uuid"

"github.com/bluenviron/mediamtx/internal/conf"
"github.com/bluenviron/mediamtx/internal/defs"
"github.com/bluenviron/mediamtx/internal/test"
Expand All @@ -31,6 +33,22 @@ func (m *testPathManager) APIPathsGet(name string) (*defs.APIPath, error) {
return path, nil
}

func (m *testPathManager) APIPushTargetsList(_ string) (*defs.APIPushTargetList, error) {
return &defs.APIPushTargetList{Items: []*defs.APIPushTarget{}}, nil
}

func (m *testPathManager) APIPushTargetsGet(_ string, _ uuid.UUID) (*defs.APIPushTarget, error) {
return nil, conf.ErrPathNotFound
}

func (m *testPathManager) APIPushTargetsAdd(_ string, _ defs.APIPushTargetAdd) (*defs.APIPushTarget, error) {
return &defs.APIPushTarget{}, nil
}

func (m *testPathManager) APIPushTargetsRemove(_ string, _ uuid.UUID) error {
return nil
}

func TestPathsList(t *testing.T) {
now := time.Now()
pathManager := &testPathManager{
Expand Down
Loading
Loading