Ejemplo n.º 1
0
bool CGstPlayback::Init()
{
    returnv_assert(!m_playbin, true);

    g_print("%s, begin", __func__);

    m_playbin = gst_element_factory_make ("playbin", "playbin");
    returnb_assert(m_playbin);

    GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE(m_playbin));
    returnb_assert(bus);
    gst_bus_add_watch (bus, (GstBusFunc)handle_message, this);
    gst_object_unref (bus);

    //m_audio_sink = gst_element_factory_make("autoaudiosink", NULL);
    //returnb_assert(m_audio_sink);
    //g_object_set (GST_OBJECT(m_playbin), "audio-sink", m_audio_sink, NULL);

    //m_video_sink = gst_element_factory_make("eglglessink", NULL);
    //returnb_assert(m_video_sink);
    //g_object_set (GST_OBJECT(m_playbin), "video-sink", m_video_sink, NULL);

    g_print("%s, end", __func__);

    return true;
}
Ejemplo n.º 2
0
bool CGstPlayback::SetWindow(void *window)
{
    returnb_assert(m_playbin);

    g_print("%s, get GST_TYPE_VIDEO_OVERLAY", __func__);
    m_video_sink = gst_bin_get_by_interface(GST_BIN(m_playbin), GST_TYPE_VIDEO_OVERLAY);
    returnb_assert(m_video_sink);

    g_print("%s, set native window=(%x)", __func__, window);
    gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (m_video_sink), (guintptr)window);
    return true;
}
Ejemplo n.º 3
0
bool CEauApi::DelProjectUser(const string &pid, const string &uid)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter == m_vProjs.end())
        return false;

    proj_t &proj = iter->second;
    map<string, user_t>::iterator uiter = proj.users.find(m_szUser);
    if (uiter == proj.users.end())
        return false;
    user_t &user = uiter->second;
    if (user.role != "owner") // only project owner have permission
        return false; 

    if (uid == proj.creator)
        return false; // cannot del user who also is project owner

    uiter = proj.users.find(uid);
    if (uiter == proj.users.end()) 
        return false; // user not exist

    if (uiter->second.role == "owner") {
        // owner can only be deleted by creator
        if (proj.creator != m_szUser)
            return false;
    }
    proj.users.erase(uid);
    return true;
}
Ejemplo n.º 4
0
bool CGstPlayback::SetUri(const char *uri)
{
    returnb_assert(m_playbin);

    g_print("%s, set uri=%s", __func__, uri);
    g_object_set (m_playbin, "uri", uri, NULL);
    return true;
}
Ejemplo n.º 5
0
bool CEauApi::SignIn(const char *name, const char *pass)
{
    returnb_assert(!m_bSigned);
    m_szUser = string(name);
    m_szPass = string(pass);
    m_bSigned = true;
    return true;
}
Ejemplo n.º 6
0
bool CEauApi::GetProjects(vector<string> &pids)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.begin();
    for(iter=m_vProjs.begin(); iter != m_vProjs.end(); iter++) {
        pids.push_back(iter->first);
    }
    return true;
}
Ejemplo n.º 7
0
bool CEauApi::SetProjectBill(const string &pid, const string &bid, string todo_val)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter == m_vProjs.end())
        return false;

    proj_t &proj = iter->second;
    map<string, bill_t>::iterator biter = proj.bills.find(bid);
    if (biter == proj.bills.end())
        return false;

    bill_t &bill = biter->second;
    if (bill.stat == "approve" || bill.stat == "refuse") // final stat
        return false;

    // bill creator can set bill stat
    if (bill.creator == m_szUser) { // nop for bill creator
        if (todo_val == "no")
            bill.stat = "desperate";
        return true;
    }

    if (bill.stat == "desperate") // final stat
        return false;

    // project owner can set bill stat
    map<string, user_t>::iterator uiter = proj.users.find(m_szUser);
    if (uiter == proj.users.end())
        return false;
    user_t &user = uiter->second;
    if (user.role != "owner")
        return false; 

    map<string, string>::iterator titer = user.todo.find(m_szUser);
    if (titer == user.todo.end())
        return false;
    user.todo[m_szUser] = todo_val;

    // check bill stat
    string bstat = "approve";
    for(titer=bill.todo.begin(); titer != bill.todo.end(); titer++) {
        if (titer->second == "no") {
            bstat = "refuse"; // final stat
            break;
        }else if (titer->second == "yes") {
            // continue;
        }else { // "ing"
            bstat = "wait";
        }
    }
    bill.stat = bstat;
    return true;
}
Ejemplo n.º 8
0
bool CEauApi::GetProjectInfo(const string &pid, pinfo_t &pinfo)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter != m_vProjs.end()) {
        pinfo = iter->second;
        return true;
    }
    return false;
}
Ejemplo n.º 9
0
bool CGstPlayback::SetOption()
{
    returnb_assert(m_playbin);

    ALOGI("%s, set flags", __func__);
    g_object_get (m_playbin, "flags", &m_flags, NULL);
    m_flags |= GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO;
    m_flags &= ~GST_PLAY_FLAG_TEXT;
    g_object_set (m_playbin, "flags", m_flags, NULL);
    //g_object_set (m_playbin, "connection-speed", 56, NULL);
    return true;
}
Ejemplo n.º 10
0
bool CGstPlayback::Stop()
{
    returnb_assert(m_playbin);

    g_print("%s, begin", __func__);
    gint iret = gst_element_set_state (m_playbin, GST_STATE_READY);
    if (iret == GST_STATE_CHANGE_FAILURE) {
        g_printerr ("Unable to set the pipeline to the playing state.\n");
        return false;
    }
    return true;
}
Ejemplo n.º 11
0
bool CGstPlayback::Play()
{
    returnb_assert(m_playbin);

    g_print("%s, begin", __func__);
    gint iret = gst_element_set_state (m_playbin, GST_STATE_PLAYING);
    if (iret == GST_STATE_CHANGE_FAILURE) {
        g_printerr ("Unable to set the pipeline to the playing state.\n");
        return false;
    }

    if (!m_main_loop) {
        m_main_loop = g_main_loop_new (NULL, FALSE);
    }

    returnb_assert(m_main_loop);
    m_bus_msg_thread = g_thread_create ((GThreadFunc)g_main_loop_run, m_main_loop, TRUE, NULL);
    returnb_assert(m_bus_msg_thread);

    return true;
}
Ejemplo n.º 12
0
bool CGstPlayback::Prepare()
{
    returnb_assert(m_playbin);

    g_print("%s, set ready state", __func__);
    // Set the pipeline to READY, so it can already accept a window handle, if we have one
    gint iret = gst_element_set_state(m_playbin, GST_STATE_READY);
    if (iret == GST_STATE_CHANGE_FAILURE) {
        g_printerr ("Unable to set the pipeline to the ready state.\n");
        return false;
    }

    return true;
}
Ejemplo n.º 13
0
bool CEauApi::GetProjectBillInfo(const string &pid, const string &bid, binfo_t &binfo)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter != m_vProjs.end()) {
        map<string, bill_t> &bills = iter->second.bills;
        map<string, bill_t>::iterator biter = bills.find(bid);
        if (biter != bills.end()) {
            binfo = biter->second;
            return true;
        }
    }
    return false;
}
Ejemplo n.º 14
0
bool CEauApi::GetProjectBills(const string &pid, vector<string> &bids)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter != m_vProjs.end()) {
        map<string, bill_t> &bills = iter->second.bills;
        map<string, bill_t>::iterator biter;
        for (biter=bills.begin(); biter != bills.end(); biter++) {
            bids.push_back(biter->first);
        }
        return true;
    }
    return false;
}
Ejemplo n.º 15
0
bool CEauApi::GetProjectUserInfo(const string &pid, const string &uid, uinfo_t &uinfo)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter != m_vProjs.end()) {
        map<string, user_t> &users = iter->second.users;
        map<string, user_t>::iterator uiter = users.find(uid);
        if (uiter != users.end()) {
            uinfo = uiter->second;
            return true;
        }
    }
    return false;
}
Ejemplo n.º 16
0
bool CEauApi::GetProjectUsers(const string &pid, vector<string> &uids)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter != m_vProjs.end()) {
        map<string, user_t> &users = iter->second.users;
        map<string, user_t>::iterator uiter;
        for (uiter=users.begin(); uiter != users.end(); uiter++) {
            uids.push_back(uiter->first);
        }
        return true;
    }

    return false;
}
Ejemplo n.º 17
0
bool CEauApi::AddProject(pinfo_t &pinfo)
{
    returnb_assert(m_bSigned);

    pinfo.pid = uuid_generate_string();
    pinfo.creator = m_szUser;
    pinfo.cdate = now_to_string();
    pinfo.mdate = pinfo.cdate;
    proj_t proj(pinfo);

    // default project creator is also owner
    user_t user;
    user.uid = m_szUser;
    user.role = "owner";
    user.stat = "approve";
    proj.users[user.uid] = user;

    m_vProjs[pinfo.pid] = proj;
    return true;
}
Ejemplo n.º 18
0
bool CEauApi::AddProjectBill(const string &pid, binfo_t &binfo)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter == m_vProjs.end())
        return false;
    
    // only project owner and member can add new bill
    proj_t &proj = iter->second;
    map<string, user_t>::iterator uiter = proj.users.find(m_szUser);
    if (uiter == proj.users.end())
        return false;
    user_t &user = uiter->second;
    if (user.role != "owner" && user.role != "member")
        return false; 

    // gen bill id(bid)
    binfo.bid = uuid_generate_string();
    binfo.creator = m_szUser;
    binfo.cdate = now_to_string();
    binfo.mdate = binfo.cdate;

    // set bill stat
    bill_t bill(binfo);
    bill.stat = "wait";
    // new bill need all owners' permission
    for(uiter=proj.users.begin(); uiter != proj.users.end(); uiter++) {
        if (uiter->second.role == "owner")
            bill.todo[uiter->first] = "ing";
    }

    // if only one owner and also he/she is bill creator
    if (bill.todo.find(m_szUser) != bill.todo.end()) {
        bill.todo[m_szUser] = "yes";
        if (bill.todo.size() == 1)
            bill.stat = "approve";
    }
    proj.bills[binfo.bid] = bill;
    return true;
}
Ejemplo n.º 19
0
bool CEauApi::AddProjectUser(const string &pid, uinfo_t &uinfo)
{
    returnb_assert(m_bSigned);

    map<string, proj_t>::iterator iter = m_vProjs.find(pid);
    if (iter == m_vProjs.end())
        return false;

    proj_t &proj = iter->second;
    map<string, user_t>::iterator uiter = proj.users.find(m_szUser);
    if (uiter == proj.users.end())
        return false;
    user_t &user = uiter->second;
    if (user.role != "owner") // only project owner have permission
        return false; 

    uiter = proj.users.find(uinfo.uid);
    if (uiter != proj.users.end()) 
        return false; // user exist
    
    user_t new_user(uinfo);
    new_user.stat = "approve";
    if (uinfo.role == "owner") {
        // new owner need all owners' permission
        new_user.stat = "wait";
        for(uiter=proj.users.begin(); uiter != proj.users.end(); uiter++) {
            if (uiter->second.role == "owner")
                new_user.todo[uiter->first] = "ing";
        }

        // self owner approve automatically
        if (new_user.todo.find(m_szUser) != new_user.todo.end()) {
            new_user.todo[m_szUser] = "yes";
            if (new_user.todo.size() == 1)
                new_user.stat = "approve";
        }
    }
    proj.users[new_user.uid] = new_user;
    return true;
}
Ejemplo n.º 20
0
bool CEauApi::SignOut()
{
    returnb_assert(m_bSigned);
    m_bSigned = false;
    return true;
}