Skip to content

Commit

Permalink
新增方法
Browse files Browse the repository at this point in the history
  • Loading branch information
wanjiewu committed Mar 15, 2024
1 parent 0268b78 commit 9762204
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions ci_media.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cos

import (
"bytes"
"context"
"encoding/json"
"encoding/xml"
Expand All @@ -9,6 +10,7 @@ import (
"net/http"
"sort"
"strings"
"time"

"github.com/clbanning/mxj"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -1506,6 +1508,80 @@ func (s *CIService) GenerateMediaInfo(ctx context.Context, opt *GenerateMediaInf
return &res, resp, err
}

// GenerateMediaInfoOptions TODO
type GenerateAVInfoOptions struct {
XMLName xml.Name `xml:"Request"`
Input *JobInput `xml:"Input,omitempty"`
OptHeaders *OptHeaders `header:"-,omitempty" url:"-" json:"-" xml:"-"`
}
type GetAVInfoResult struct {
Format struct {
BitRate string `json:"bit_rate"`
Duration string `json:"duration"`
FormatLongName string `json:"format_long_name"`
FormatName string `json:"format_name"`
NbPrograms int `json:"nb_programs"`
NbStreams int `json:"nb_streams"`
Size string `json:"size"`
StartTime string `json:"start_time"`
} `json:"format"`
Streams []struct {
AvgFrameRate string `json:"avg_frame_rate,omitempty"`
BitRate string `json:"bit_rate"`
CodecLongName string `json:"codec_long_name"`
CodecName string `json:"codec_name"`
CodecTag string `json:"codec_tag"`
CodecTagString string `json:"codec_tag_string"`
CodecTimeBase string `json:"codec_time_base"`
CodecType string `json:"codec_type"`
ColorPrimaries string `json:"color_primaries,omitempty"`
ColorRange string `json:"color_range,omitempty"`
ColorTransfer string `json:"color_transfer,omitempty"`
CreationTime time.Time `json:"creation_time"`
DisplayAspectRatio string `json:"display_aspect_ratio,omitempty"`
Duration string `json:"duration"`
FiledOrder string `json:"filed_order,omitempty"`
HasBFrames string `json:"has_b_frames,omitempty"`
Height int `json:"height,omitempty"`
Index int `json:"index"`
Language string `json:"language"`
Level int `json:"level,omitempty"`
NbFrames string `json:"nb_frames,omitempty"`
PixFmt string `json:"pix_fmt,omitempty"`
Profile string `json:"profile,omitempty"`
RFrameRate string `json:"r_frame_rate,omitempty"`
Refs int `json:"refs,omitempty"`
Rotation string `json:"rotation,omitempty"`
SampleAspectRatio string `json:"sample_aspect_ratio,omitempty"`
StartTime string `json:"start_time"`
Timebase string `json:"timebase"`
Width int `json:"width,omitempty"`
ChannelLayout string `json:"channel_layout,omitempty"`
Channels int `json:"channels,omitempty"`
SampleFmt string `json:"sample_fmt,omitempty"`
SampleRate string `json:"sample_rate,omitempty"`
} `json:"streams"`
}

// GenerateMediaInfo TODO
// 生成媒体信息接口,支持大文件,耗时较大请求
func (s *CIService) GenerateAVInfo(ctx context.Context, opt *GenerateAVInfoOptions) (*GetAVInfoResult, *Response, error) {
var buf bytes.Buffer
var res GetAVInfoResult
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/avinfo",
method: http.MethodPost,
body: opt,
result: &buf,
}
resp, err := s.client.send(ctx, &sendOpt)
if buf.Len() > 0 {
err = json.Unmarshal(buf.Bytes(), &res)
}
return &res, resp, err
}

// GetSnapshotOptions TODO
type GetSnapshotOptions struct {
Time float32 `url:"time,omitempty"`
Expand Down Expand Up @@ -1572,6 +1648,19 @@ func (s *CIService) PostSnapshot(ctx context.Context, opt *PostSnapshotOptions)
return &res, resp, err
}

// PostCISnapshot
func (s *CIService) PostCISnapshot(ctx context.Context, opt *PostSnapshotOptions) (*Response, error) {
sendOpt := sendOptions{
baseURL: s.client.BaseURL.CIURL,
uri: "/cisnapshot",
body: opt,
method: http.MethodPost,
disableCloseBody: true,
}
resp, err := s.client.send(ctx, &sendOpt)
return resp, err
}

// GetPrivateM3U8Options TODO
type GetPrivateM3U8Options struct {
Expires int `url:"expires"`
Expand Down

0 comments on commit 9762204

Please sign in to comment.