小编Ali*_*slo的帖子

通过使用swift中的CocoaAsyncSocket通过UDP传输音频

我有一个问题是通过UDP在swift中通过CocoaAsyncSocket发送音频.

首先,我运行下面的代码开始监听4444 UDP端口.

vlc --demux=rawaud --rawaud-channels=1 --rawaud-samplerate=48000 udp://@:4444
Run Code Online (Sandbox Code Playgroud)

之后我在iPad2上运行我的应用程序并按连接.

import UIKit
import CocoaAsyncSocket
import AVFoundation
class ViewController: UIViewController , GCDAsyncUdpSocketDelegate {

var avAudioEngine : AVAudioEngine?

@IBAction func btnAction(sender: UIButton) {

    avAudioEngine = AVAudioEngine()
    let input = avAudioEngine?.inputNode

    let socket = GCDAsyncUdpSocket(delegate: self, delegateQueue: dispatch_get_main_queue())
    do {
        try socket.bindToPort(4445)
        try socket.connectToHost("192.168.0.137",onPort : 4444)
        try socket.beginReceiving()

        input?.installTapOnBus(0, bufferSize: 2048, format: input?.inputFormatForBus(0), block: { (buffer : AVAudioPCMBuffer, timeE: AVAudioTime) -> Void in
            socket.sendData(self.toNSData(buffer), withTimeout: 0, tag: 0)
        })

        avAudioEngine?.prepare()
        try avAudioEngine?.start()

        // with …
Run Code Online (Sandbox Code Playgroud)

udp ios cocoaasyncsocket swift avaudioengine

8
推荐指数
0
解决办法
754
查看次数

在Sails js中检查上传的文件扩展名

我们如何在sails js中检查上传的文件扩展名?我试过船长闷热但没有结果.有什么建议吗?

node.js sails.js

3
推荐指数
1
解决办法
2193
查看次数

swift iOS从异步中获取价值(发布数据)

我有一个问题是在异步过程中获取值.

我的班级是:

public class PostService: NSObject {

var result : String = String()

//this is my function


func request(var dataPost : String, var destination : String)->String{

    let request = NSMutableURLRequest(URL: NSURL(string: destination as String)!)
    request.HTTPMethod = "POST"
    let postString = dataPost
    request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
    let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
        data, response, error in

        if error != nil {
            println("error=\(error)")
            return
        }

        let responseString = NSString(data: data, encoding: NSUTF8StringEncoding)

        self.result = responseString as String!

    }

    task.resume()

//problem is here that result …
Run Code Online (Sandbox Code Playgroud)

asynchronous listener dispatch ios swift

2
推荐指数
1
解决办法
2866
查看次数

AWS cloudfront 在不使用 Lambda@Edge 的情况下添加自定义标头

我想将x-frame-options作为同源添加到在S3存储桶上为我的应用程序提供服务的AWS CloudFront服务。

我不想添加新的Lambda函数来编辑请求标头。

其实我在附件中找到了一个地方:

CloudFront Distributions -> My Distribution settings -> Origins and Origin Groups -> S3 Content item that代表我的应用程序 -> add Origin Custom Headers -> Header name: x-frame-options , Value : sameorigin

但是当部署完成时,仍然在 S3 存储桶文件和 URL 的所有相关请求中获取旧标头。

在此处输入图片说明

我如何在没有任何 Lambda 函数的情况下添加到标头,而只是直接使用现有的 AWS CloudFront 面板?

amazon-s3 custom-headers amazon-cloudfront

1
推荐指数
3
解决办法
4820
查看次数